sparkline(YaleToolkit)
sparkline()所属R语言包:YaleToolkit
Draws a sparkline
绘制的迷你
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Draws a times series or "sparkline" in a compact iconic fashion suitable for inclusion in more complex graphics or text.
绘制一个时间序列或“迷你图”在一个紧凑的标志性时尚,适合纳入更复杂的图形或文字。
用法----------Usage----------
sparkline(s, times = NULL, ylim = NULL, buffer = unit(0, "lines"),
margins = NULL, IQR = NULL, yaxis = FALSE, xaxis = FALSE,
ptopts = list(points = NULL, labels = NULL, labels.ch = NULL,
gp = NULL, just = NULL, pch = NULL), margin.pars = NULL,
buffer.pars = NULL, frame.pars = NULL, line.pars = gpar(lwd = 1),
main = NULL, sub = NULL, xlab = NULL, ylab = NULL, new = TRUE)
参数----------Arguments----------
参数:s
a vector or time series (class "ts" or "zoo") giving the data to be plotted. If s is a time series, the start, end, and frequency found in attributes(s)$tsp are automatically converted into an argument to times.
的向量或时间序列(类"ts"或"zoo")给要绘制的数据。如果s是一个时间序列,start,end和frequency发现在attributes(s)$tsp会自动转换成一个参数times的。
参数:times
the times at which to plot the data; if NULL (the default), equal spacing is assumed, equivalent to setting times = 1:length(s).
时代在绘制的数据,如果NULL(默认值),间距相等的假设,相当于设置times = 1:length(s)。
参数:ylim
the maximum and minimum value on the y-axis; if NULL, defaults to the actual maximum and minimum of the data.
在y-轴的最大值和最小值;如果NULL,默认为实际的数据的最大值和最小值。
参数:buffer
a buffer above the maximum and below the minimum values attained by the sparkline. Defaults to unit(0, 'lines').
以上的缓冲器的最大和低于最低值达到由迷你图。默认为unit(0, 'lines')的。
参数:margins
margins around the sparkline-plus-buffer area. NULL (the default) provides no margins; the value passed must be a 4-vector of units giving the bottom, left, top and right margins in that order.
的迷你图加缓冲区域周围的边距。 NULL(默认值)不提供空间;传递的值必须是一个4向量单位给予的底部,左侧,顶部和右页边距的顺序。
参数:IQR
a list of graphics parameters to shade or otherwise delineate the interquartile range of the sparkline. NULL (the default), does not show the IQR. See Details for more information.
一个阴影或以其他方式划定的四分位距的迷你图的图形参数列表。 NULL(默认设置),不表明IQR。见Details更多信息。
参数:yaxis
draws a vertical axis if TRUE; defaults to FALSE in which case no axis is drawn.
TRUE默认FALSE在这种情况下,无轴绘制,绘制一条垂直的轴。
参数:xaxis
'interior' draws a horizontal axis inside the plotting frame; 'exterior' outside the plotting frame (in the margins); defaults to FALSE, in which case no axis is drawn.
'interior'绘制一个水平轴的绘图框架内; 'exterior'在图形外框架(边距),默认FALSE,在这种情况下,无轴画。
参数:ptopts
a list of graphics parameters describing the points on the sparkline that are plotted and labelled. In particular the first and last or minimum and maximum points are labeled if ptopts$labels is 'first.last' or 'min.max'. In addition to labels, other relevant parameters from gpar should be valid. See Details for more information.
图形参数的列表描述的迷你图,绘制和标记点。尤其是第一个和最后或最低点和最高点被标记为ptopts$labels如果是'first.last'或'min.max'。此外labels,其他相关参数gpar应该是有效的。见Details更多信息。
参数:margin.pars
a list of graphics parameters describing the margin area. See Details for more information.
图形参数描述边缘区的一个列表。见Details更多信息。
参数:buffer.pars
a list of graphics parameters describing the buffer area. See Details for more information.
图形参数描述的缓冲区域的列表。见Details更多信息。
参数:frame.pars
a list of graphics parameters describing the exact area taken up by the plotted sparkline. See Details for more information.
图形参数的确切面积绘制的迷你图的列表。见Details更多信息。
参数:line.pars
a list of graphics parameters describing the sparkline. See Details for more information.
图形参数的列表描述了迷你图。见Details更多信息。
参数:main
a main title, above the sparkline.
一个主标题,上面的迷你图。
参数:sub
a subtitle, to the right of the sparkline.
字幕,到右侧的迷你图。
参数:xlab
a string to label the x-axis.
一个字符串标记的x轴。
参数:ylab
a string to label the y-axis.
一个字符串的标签的y轴。
参数:new
defaults to TRUE, which creates a new, empty page; otherwise adds the sparkline to an existing plot.
默认的TRUE,这将创建一个新的空页;否则的迷你图添加到现有的图谋。
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(). In particular, note that ptopts takes the following non-standard parameters: labels, a vector indexing the points to label or the string 'min.max' or 'first.last'; labels.ch, a vector of strings giving the labels; and points, a vector indexing the points at which points should be plotted. Passing 'min.max' or 'first.last' to ptopts$labels overrides any values of ptopts$labels.ch.
在所有的情况下,一个图形参数列表是必要的,有效的参数名称是一样的将是有效的传递给gpar:在适当的呼叫。也就是说,通过list(fill = 'blue', col = 'red')margin给出了边缘地带,那是蓝色与红色的边框,但加上fontface = 'bold'不会有任何效果,只是因为它不会产生任何影响,打检测给grid.rect()。特别要注意的是ptopts采取以下的非标准参数:labels,一个向量的点的索引标签或字符串'min.max'或'first.last'; labels.ch 给标签的字符串,矢量和points,应绘制的点,点的向量索引。通过'min.max'或'first.last'到ptopts$labels覆盖任何值ptopts$labels.ch。
注意----------Note----------
This is primarily intended to be called by other functions (sparklines() and sparkmat()), but it can also be used as an alternative to ts.plot(). Thanks to Gabor Grothendieck for suggesting the generalization that provides support of "zoo" objects.
这主要是通过以下被称为其他功能(sparklines()和sparkmat()),但它也可以被用来作为一种替代ts.plot()的。感谢到的Gabor格罗滕迪克建议的推广提供支持"zoo"对象。
(作者)----------Author(s)----------
John W. Emerson, Walton Green
参考文献----------References----------
<h3>See Also</h3>
实例----------Examples----------
### sparkline examples[##迷你图的例子]
data(nhtemp)
## The default behaviour of sparkline[#默认行为的迷你图]
sparkline(nhtemp)
## Creating stand-alone plots[#创建独立的图]
sparkline(rnorm(10),
buffer = unit(1, "lines"),
ptopts = 'first.last',
margins = unit(c(1,1,1,1), 'inches'),
yaxis = TRUE, xaxis=TRUE,
IQR = gpar(fill = 'grey', col = 'grey'),
main = "Ten Random Standard Normal Numbers",
sub = '...plotted here')
data(YaleEnergy)
y <- YaleEnergy[YaleEnergy$name==YaleEnergy$name[2],]
sparkline(y$ELSQFT, times=y$year+y$month/12,
xaxis=TRUE, yaxis=TRUE, main="Branford College Electrical Consumption",
buffer=unit(1, "lines"), margins = unit(c(1, 1, 1, 1), 'inches'))
sparkline(Nile,
buffer = unit(1, "lines"),
ptopts = list(labels = 'min.max'),
margin.pars = gpar(fill = 'lightblue'),
buffer.pars = gpar(fill = 'lightgreen'),
frame.pars = gpar(fill = 'lightyellow'),
yaxis = TRUE, xaxis=TRUE,
IQR = gpar(fill = 'grey', col = 'grey'),
main="Nile Discharge between 1871 and 1970",
sub='In what units?')
## Adding a sparkline to an existing plot[#添加的迷你现有的图]
grid.newpage()
pushViewport(viewport(w = 0.8, h = 0.8))
sparkline(rnorm(10),
buffer = unit(1, "lines"),
margins = unit(c(4,4,4,4),'points'),
ptopts = list(labels = 'min.max'),
margin.pars = gpar(fill = 'lightblue'),
buffer.pars = gpar(fill = 'lightgreen'),
frame.pars = gpar(fill = 'lightyellow'),
yaxis = TRUE, xaxis=TRUE,
IQR = gpar(fill = 'grey', col = 'grey'),
main="Title (plotted OUTSIDE the viewport)", new = FALSE)
popViewport()
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|