sparkmat(YaleToolkit)
sparkmat()所属R语言包:YaleToolkit
Draws a sparkmat
绘制sparkmat
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Draws multiple time series (or sparklines) at given locations.
在给定的位置,绘制多个时间序列(迷你)。
用法----------Usage----------
sparkmat(x, locs = NULL, w = NULL, h = NULL, lcol = NULL,
yscales = NULL, tile.shading = NULL,
tile.margin = unit(c(0, 0, 0, 0), "points"),
tile.pars = NULL, just = c("right", "top"),
new = TRUE, ...)
----------Arguments----------
参数:x
a list of data frames, all with the same dimensions, one for each panel of vertically aligned sparklines.
列表中的数据框,都具有相同的尺寸,其中每个面板垂直排列的走势图。
参数:locs
a data frame with x-coordinates in the first variable and y-coordinates in the second variable, giving locations of each of the length(x) sparkline panels.
一个数据框的x坐标在第一个变量坐标和y坐标在所述第二变量,给每个length(x)迷你图板的位置。
参数:w
vector of unit widths (or native widths if not specified as units).
向量的单位宽度(或本机的宽度,如果没有指定单位)。
参数:h
vector of unit heights (or native heights if not specified as units).
如果没有指定单位矢量单元的高度(或本机的高度)。
参数:lcol
vector of ncol(x[[1]]) line colors, one for each sparkline in each panel.
ncol(x[[1]])线的颜色,为每个迷你图在每个面板之一的矢量。
参数:yscales
either a vector of length 2 giving the y-limits for all sparklines, or a list having the same length as the number of columns in ss (each component of which is a 2-vector giving scales for the individual sparklines). Defaults to NULL, in which case the scales for each sparkline are set to its minimum and maximum value within the panel.
无论是矢量长度为2的y-限制可用于所有迷你图,或在ss(其中每个组件是一个2 - 矢量给个别迷你尺度)的数目的列具有相同的长度的列表作为。默认NULL,在这种情况下,每个迷你图的尺度,其面板内的最小值和最大值设置为。
参数:tile.shading
vector of background shadings for the panels.
矢量面板的背景阴影。
参数:tile.margin
an outer margin around each tile (panel of sparklines). A 4-vector of units giving the bottom, left, top and right margins; defaults to unit(c(0,0,0,0), 'points').
外缘周围每瓦(迷你面板)。 A 4矢量单位给予的底部,左侧,顶部和右页边距默认为unit(c(0,0,0,0), 'points')。
参数:tile.pars
a list of graphics parameters describing the buffer area. See Details for more information.
图形参数描述的缓冲区域的列表。见Details更多信息。
参数:just
default is c("right", "top"); controls the justification of the sparklines relative to the provided location coordinates.
默认是c("right", "top");控制的迷你相对于所提供的位置坐标的理由。
参数:new
defaults to TRUE, which creates a new, empty page; otherwise adds the sparkline to the existing plot.
默认的TRUE,这将创建一个新的空页;否则的迷你图添加到现有的图。
参数:...
for arguments to be passed through to sparklines().
为参数传递到sparklines()。
Details
详细信息----------Details----------
In all the cases where a list of graphics parameters is needed, the valid parameter names are the same as would be valid when passed to gpar in the appropriate call. That is, passing list(fill = 'blue', col = 'red') to margin gives a margin that is blue with a red border; but adding fontface = 'bold' will have no effect, just as it would have no effect in a call to grid.rect().
在所有的情况下,一个图形参数列表是必要的,有效的参数名称相同,将是有效的传递给GPAR在适当的呼叫。也就是说,通过list(fill = 'blue', col = 'red')margin给出了边缘地带,那是蓝色与红色的边框,但加上fontface = 'bold'不会有任何效果,只是因为它不会产生任何影响,打检测给grid.rect()。
(作者)----------Author(s)----------
John W. Emerson, Walton Green
参考文献----------References----------
<h3>See Also</h3>
实例----------Examples----------
# An example with a time series of energy consumption at Yale colleges.[例如,一个时间序列的能源消耗在耶鲁大学院校。]
data(YaleEnergy)
y <- YaleEnergy
# Need list of 12 data frames, each with one time series.[需要12个数据框,每帧的一个时间序列的列表。]
z <- list(data.frame(y[y$name==y$name[1],"ELSQFT"]),
data.frame(y[y$name==y$name[2],"ELSQFT"]),
data.frame(y[y$name==y$name[3],"ELSQFT"]),
data.frame(y[y$name==y$name[4],"ELSQFT"]),
data.frame(y[y$name==y$name[5],"ELSQFT"]),
data.frame(y[y$name==y$name[6],"ELSQFT"]),
data.frame(y[y$name==y$name[7],"ELSQFT"]),
data.frame(y[y$name==y$name[8],"ELSQFT"]),
data.frame(y[y$name==y$name[9],"ELSQFT"]),
data.frame(y[y$name==y$name[10],"ELSQFT"]),
data.frame(y[y$name==y$name[11],"ELSQFT"]),
data.frame(y[y$name==y$name[12],"ELSQFT"]))
sparkmat(z, locs=data.frame(y$lon, y$lat), new=TRUE,
w=0.002, h=0.0002, just=c("left", "top"))
grid.text(y[1:12,1], unit(y$lon[1:12]+0.001, "native"),
unit(y$lat[1:12]+0.00003, "native"),
just=c("center", "bottom"), gp=gpar(cex=0.7))
grid.text("Degrees Longitude", 0.5, unit(-2.5, "lines"))
grid.text("Degrees Latitude", unit(-4.5, "lines"), 0.5, rot=90)
grid.text("Monthly Electrical Consumption (KwH/SqFt)",
0.5, 0.82, gp=gpar(cex=1, font=2))
grid.text("of Yale Residential Colleges",
0.5, 0.77, gp=gpar(cex=1, font=2))
grid.text("July 1999 - July 2006",
0.5, 0.72, gp=gpar(cex=1, font=2))
# An example with pressure and high cloud cover over a regular grid of the[例如通过常规电网的压力和高云盖]
# Americas, provided by NASA ().[美洲,由NASA()提供的。]
runexample <- FALSE
if (runexample) {
data(nasa)
grid.newpage()
pushViewport(viewport(w = unit(1, "npc")-unit(2, "inches"),
h = unit(1, "npc")-unit(2, "inches")))
v <- viewport(xscale = c(-115, -55),
yscale = c(-22.5, 37.5))
pushViewport(v)
y <- vector(mode="list", length=24*24)
locs <- as.data.frame(matrix(0, 24*24, 2))
tile.shading <- rep(0, 24*24)
for(i in 1:24) { # Latitudes[纬度]
for(j in 1:24) { # Longitudes[经度]
y[[(i-1)*24+j]] <- as.data.frame(t(nasa$data[,,i,j]))
locs[(i-1)*24+j,] <- c(as.numeric(dimnames(nasa$data)$lon[j]),
as.numeric(dimnames(nasa$data)$lat[i]))
tile.shading[(i-1)*24+j] <- gray( 1-.5*(nasa$elev[i,j]/max(nasa$elev)) )
}
}
yscales <- list(quantile(nasa$data["pressure",,,], c(0.01, 0.99), na.rm=TRUE),
quantile(nasa$data["cloudhigh",,,], c(0.01, 0.99), na.rm=TRUE))
sparkmat(y, locs=locs, just='center', w=2.5, h=2.5,
tile.shading=tile.shading, lcol=c(6,3), yscales=yscales,
tile.margin = unit(c(2,2,2,2), 'points'), new=FALSE)
grid.xaxis(gp=gpar(fontface=2, fontsize=14))
grid.yaxis(gp=gpar(fontface=2, fontsize=14))
grid.rect()
grid.text("Degrees Latitude", x=unit(-0.75, "inches"), y=0.5, rot=90,
gp=gpar(fontface=2, fontsize=14))
grid.text("Degrees Longitude", x=0.5, y=unit(-0.75, "inches"), rot=0,
gp=gpar(fontface=2, fontsize=14))
grid.text("Grayscale shading reflects",
x=unit(1, "npc")+unit(0.6, "inches"), y=0.5, rot=270,
gp=gpar(fontface=2, fontsize=14))
grid.text("average elevation above sea level",
x=unit(1, "npc")+unit(0.3, "inches"), y=0.5, rot=270,
gp=gpar(fontface=2, fontsize=14))
grid.lines(nasa$coast[,1], nasa$coast[,2], default.units = 'native',
gp = gpar(col = 'black', lwd = 1))
grid.text("Pressure",
x=0.25, y=unit(1, "npc")+unit(1.25, "lines"),
gp=gpar(fontface=2, fontsize=14))
grid.rect(x=0.25, y=unit(1, "npc") + unit(0.5, "lines"),
width=0.4, height=unit(0.05, "inches"), gp=gpar(col=6, fill=6))
grid.text("High Cloud",
x=0.75, y=unit(1, "npc")+unit(1.25, "lines"),
gp=gpar(fontface=2, fontsize=14))
grid.rect(x=0.75, y=unit(1, "npc") + unit(0.5, "lines"),
width=0.4, height=unit(0.05, "inches"), gp=gpar(col=3, fill=3))
}
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|