Reputation: 715
I use R to plot a figure as follows
grid=10
library(matlab)
lambda_grids=exp(linspace(log(1),log(1e-4),grid))
plot(lambda_grids,type='l',xlab="", ylab="",yaxt="n")
By default, we can see axes (x-axis) taking 2, 4, 6, 8, 10.
I want axes showing sth like
axes=expression(lambda[2],lambda[4],lambda[6],lambda[8],lambda[10])
Does anyone konw how to achieve this? Tks!
Upvotes: 2
Views: 478
Reputation: 2874
I'm not sure if I understand your desired output, but you could achieve this by using axis()
after you plotted your plot.
First you need to insert axes = FALSE
(no axes labels) and frame.plot = TRUE
(frame around plot) in your plot()
code like this
plot(lambda_grids, type = 'l', axes = FALSE, frame.plot=TRUE, xlab = "", ylab = "", yaxt = "n")
After that you use
axis(side = 1, at = c(2, 4, 6, 8, 10),labels = c(expression(lambda [2]), expression(lambda [4]),
expression(lambda [6]), expression(lambda [8]), expression(lambda [10])))
And the output
Upvotes: 2