我没有在x标签中添加数学符号,而是试图在0处添加$ t_ [1,n] $,$ t_ [2,n] $和$ t_ [3,n] $符号,x轴值分别为40和85点。为此,我的代码是
m=c(rnorm(40,0,.5),rnorm(45,5,.5));
plot(rep(1:85,1), m, type="l", lty=1, xaxt='n', yaxt='n',ann=FALSE, col=4);
windowsFonts(script=windowsFont("Script MT Bold"));
title(xlab=c(expression(t[1,n]), expression(t[2,n]), expression(t[3,n])), family="script");
答案 0 :(得分:2)
也许可以尝试ggplot2
,就像这里:
library("ggplot2")
x <- 1:85
y <- c(rnorm(40,0,.5), rnorm(45,5,.5));
dane <- data.frame(x=x, y=y)
ggplot(dane, aes(x=x, y=y))+
geom_line()+
theme_bw()+
scale_x_discrete(breaks=c(1, 40, 85),
labels=c(expression(t[paste("[", 1, ",", n, "]")]),
expression(t[paste("[", 2, ",", n, "]")]),
expression(t[paste("[", 3, ",", n, "]")])))
答案 1 :(得分:0)
使用axis
代替title
。
axis(side = 1, at = c(0, 40, 85),
labels = c(expression(t["1,n"]),
expression(t["2,n"]),
expression(t["3,n"])))