I have a vectors of strings, say c("E^A","S^P","lambda","T","E^Q","E^Q","AT")
, and I want to plot them as the x axis label using math expression. (I believe I have written them in math expression format, but with quote)
When I put
text(x,par("usr")[3]-0.2,labels=substitute(A,list(A=label)),srt=20,pos=1,adj = c(1.1,1.1), xpd = TRUE,cex=0.7)
The x axis only shows "E^A","S^P","lambda","T","E^Q","E^Q","AT", not the mathematical interpretation of the strings, and I guess it's because they are not regarded as math symbols.
How can I get mathematical labeling then? Thanks so much!
Best Solution
In general, use
expression
(see?plotMath
):Note that the 'E^A' is not in quote marks.
To generate expressions from a character vector, use
parse(text=...)
: