[关于做好REVISION &编辑]
当plot.type
是"multiple"
,我们不能直接定义ylab
。 plot(ts.obj)
(S3
方法)和plot(timeSeries.obj)
(S4
方法)以colnames(obj)
为ylab
,我不知道任何使用希腊字母作为colname的方法。 (在结构的不同,主要来源于S3
和S4
的差值; colnames(timeSeries.obj)
相当于[email protected]
;默认值是Series i
和TS.i
)。
我们可以在ylab
使用arugument步骤,panel
(就是了function
,默认为lines
)。它用于for(i in 1:ncol(data))
。我不能给panel.function
一个合适的"i"
(我想它可以以某种方式,但我没有想到),所以我得到"i"
使用哪个col数据匹配。
为timeSeries
ylabs <- expression(alpha, beta, gamma, delta)
row1 <- LPP[1,]
timeSeries.panel.f <- function(x, y, ...) {
lines(x, y, ...)
mtext(ylabs[which(row1 %in% y[1])], 2, line = 3)
}
plot(LPP, panel = timeSeries.panel.f, type = "o", ann = F)
title("Title")
mtext("Time", 1, line = 3)
## If you aren't so concerned about warnings, here is more general.
## (Many functions read `...` and they return warnings).
timeSeries.panel.f2 <- function(x, y, ..., ylabs = ylabs, row1 = row1) {
lines(x, y, ...)
mtext(ylabs[which(row1 %in% y[1])], 2, line = 3)
}
plot(LPP, panel = timeSeries.panel.f2, type = "o", ann = F,
ylabs = expression(alpha, beta, gamma, delta), row1 = LPP[1,])
title("Title")
mtext("Time", 1, line = 3)
为ts
ylabs <- expression(alpha, beta, gamma)
row1 <- z[1,]
ts.panel.f <- function(y, ...) {
lines(y, ...)
mtext(ylabs[which(row1 %in% y[1])], 2, line = 3)
}
plot(z, panel = ts.panel.f, ann = F)
title("Title")
mtext("Time", 1, line = 3)
当然你也可以使用从原来的(主要是一样取得了新的功能archieve吧原版的) 。我只显示了修改后的点。
改性plot(ts.obj)
(来自plot.ts
制造)
my.plot.ts <- function(~~~, my.ylab = NULL) {
:
nm <- my.ylab # before: nm <- colnames(x)
:
}
# use
my.plot.ts(z, my.ylab = expression(alpha, beta, gamma), type = "o")
改性plot(timeSeries.obj)
# made from `.plot.timeSeries`
my.plot.timeSeries <- function(~~~, my.ylab = NULL) {
:
my.plotTimeSeries(~~~, my.ylab = my.ylab)
}
# made from `timeSeries:::.plotTimeSeries`
my.plotTimeSeries <- function(~~~, my.ylab) {
:
nm <- my.ylab # before: nm <- colnames(x)
:
}
#use
my.plot.timeSeries(LPP, my.ylab = expression(alpha, beta, gamma, delta), type="o")