Reputation: 23
Instead of adding mathematical symbols in x-labels, I'm trying to add $t_[1,n]$, $t_[2,n]$ and $t_[3,n]$ symbols at 0, 40 and 85 points in x-axis values, respectively. For doing so, my codes are
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");
Upvotes: 1
Views: 256
Reputation: 132969
Use axis
instead of title
.
axis(side = 1, at = c(0, 40, 85),
labels = c(expression(t["1,n"]),
expression(t["2,n"]),
expression(t["3,n"])))
Upvotes: 0
Reputation: 3162
Maybe try with ggplot2
, like here:
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, "]")])))
Upvotes: 2