I’m making many graphs which have same xlab. I wonder can we use xlab in theme like this:
theme_mine1 <- opts(
panel.grid.major = theme_blank()
, panel.grid.minor = theme_blank()
, panel.background = theme_blank()
, axis.line = theme_blank()
, xlab = expression(paste("My (xlab ", m^{-2}, ")"))
)
When I use this theme it doesn’t give any error or warning but it does not change the xlab. Any suggestion will be highly appreciated. Thanks
You can use
opts(labels=list(x='xlabelhere'),...).A note on how I found this out (because I didn’t know it before, and think it’s very useful):
There is a fantastic stackoverflow question on finding what can be fed in to
optshere.In summary it references the ggplot2 wiki for
opts.It also says you can use
plot_theme(p)to see all options currently applied to plotp.In your case the ggplot2
optslink didn’t yield any results for the x label, but doingplot_theme(p)onpfrom your previous questions, one could see:For your purposes,
labelslooks very promising!So then I tried:
Score! This gives me enough to go on:
Which works!