Reputation: 1364
plot.ts()
provides a convenient way to visualize multivariate time series. Unfortunately, I can't figure out how to annotate the (repeated) horizontal axes with Greek letters. The familiar approach for inserting Greek letters seems not to work and nor do some less clever approaches I've tried:
testdata = matrix(rnorm(300), ncol = 3)
# doesn't work
plot.ts(testdata, ylab = expression(paste(pi[0], " = 0")))
# doesn't work
plot.ts(testdata, ylab = c(expression(paste(pi[0], " = 0")),
expression(paste(pi[0], " = 1")),
expression(paste(pi[0], " = 2"))))
# doesn't work
colnames(testdata) = c(expression(paste(pi[0], " = 0")),
expression(paste(pi[0], " = 1")),
expression(paste(pi[0], " = 2")))
plot.ts(testdata)
# doesn't work
plot.ts(testdata, ylab = parse(text = y))
I've run out of ideas ...
Upvotes: 3
Views: 449
Reputation: 2964
There is a solution using library(zoo)
testdata = matrix(rnorm(300), ncol = 3)
plot(zoo::as.zoo(testdata),ylab=c(expression(mu),expression(sigma),expression(beta)),main="Win!")
adapted from http://r.789695.n4.nabble.com/How-to-change-the-label-in-plot-ts-td796114.html
Upvotes: 3