[關於做好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")