简体   繁体   English

R:plot.ts()的ylab中的希腊字母

[英]R: Greek letters in ylab of `plot.ts()`

plot.ts() provides a convenient way to visualize multivariate time series. plot.ts()提供了一种方便的方法来可视化多元时间序列。 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 ... 我的想法用光了...

There is a solution using library(zoo) 有使用library(zoo)的解决方案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 改编自http://r.789695.n4.nabble.com/How-to-change-the-label-in-plot-ts-td796114.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM