Subscript and tilde in ggplot2 axis tick labels?

I have axis tick labels where I'd like to be able to have both subscripts and a tilde. So I have labels like "X[y]~Z[q]". If I leave them as raw text, the tilde appears fine but the y & q aren't subscripted; if I use labels=parse(text=mylabels), the subscripts work but the tilde disappears. Any suggestions?

You need to use the plotmath syntax for the tilde: X[y] %~% Z[q]

3 Likes

Tip: you can mark an answer as the solution to your question, which keeps things tidy and helps future searchers with similar questions (don't worry if you didn't notice how to do this before — the little box you check could be way more obvious... it kind of hides amongst the other widgets)

1 Like