Reputation: 2606
say I have the plot
plot(1:10,1:10)
and I want to add the y-axis label
'this is text where I write the variable', sigma^*, 'in my favorite units'
Sigma star should be as close to latex code $\sigma^*$ as possible.
I have tried ?mathplot, and tried googling but can only find answers where the expression is at the end of a string of text and opposed to sandwiching the expression in-between text. Hence this is not a duplicate of the thread. I've tried doing things like expression(paste(...)) but that has not worked.
Upvotes: 1
Views: 263
Reputation: 6277
A call to bquote
should work for you:
plot(1:10,1:10,ylab=bquote("this is text where I write the variable" ~ sigma^"*" ~ "in my favorite units"))
Also, as we discussed in comments, if you are unhappy with the shape of the asterisk created by bquote
your options are somewhat limited... My best guess for a simple solution would be to switch to another font, like so:
plot(1:10,1:10,ylab=bquote("this is text where I write the variable" ~ sigma^symbol("*") ~ "in my favorite units"))
or to draw the aterix symbol without putting it in exponent, but then you start to be far away from the latex rendering of $\simga\^{*}$:
plot(1:10,1:10,ylab=bquote("this is text where I write the variable" ~ sigma ~ "*" ~ "in my favorite units"))
Do this help?
Upvotes: 2