How to use Greek symbols in ggplot2?
ggplot2, graphics, r, unicode, utf-8
Solution
Here is a link to an excellent wiki that explains how to put greek symbols in ggplot2. In summary, here is what you do to obtain greek symbols
- Text Labels: Use `parse = T` inside `geom_text` or `annotate`.
- Axis Labels: Use `expression(alpha)` to get greek alpha.
- Facet Labels: Use `labeller = label_parsed` inside `facet`.
- Legend Labels: Use `bquote(alpha == .(value))` in legend label.
You can see detailed usage of these options in the link
EDIT. The objective of using greek symbols along the tick marks can be achieved as follows
require(ggplot2);
data(tips);
p0 = qplot(sex, data = tips, geom = 'bar');
p1 = p0 + scale_x_discrete(labels = c('Female' = expression(alpha),
'Male' = expression(beta)));
print(p1);
For complete documentation on the various symbols that are available when doing this and how to use them, see `?plotmath`.
Problem
My categories need to be named with Greek letters. I am using `ggplot2`, and it works beautifully with the data. Unfortunately I cannot figure out how to put those greek symbols on the x axis (at the tick marks) and also make them appear in the legend. Is there any way to do it? UPDATE: I had a look at the link, however, there is no good method described to accomplish what I want to do.