0

I am using ggplot to plot some data across 5 facets and I want to put some text that says "Delta = #" where Delta is the upper case math delta symbol and # is 1,2,3,4, or 5 based on which facet it is. Here is what I have:

annotate("text",x="baseline",y=75,label=paste(expression(Delta),"=",1:5))

My line of code works but it spells out Delta rather than giving me the Delta symbol. How can I get the math symbol?

2 Answers 2

3

Try this

df <- mtcars[2:6,]
ggplot(df, aes(mpg, disp))+
  geom_point()+
  annotate("text",df$mpg,df$disp,label=paste(("Delta * '=' *"), 1:5),
  parse=TRUE, hjust = 1.1)
Sign up to request clarification or add additional context in comments.

1 Comment

Then I lose the 1:5, i.e. on each facet I should see: Delta = 1, Delta = 2, ... etc
1

annotate() will give you the same annotation on each facet, you should use geom_text() instead, with a suitable data.frame to provide the mapping.

library(ggplot2)
ggplot(data.frame(f=1:2, lab = sprintf("Delta == %i", 1:2))) + facet_wrap(~f) +
  geom_text(aes(label=lab), x=0, y=0, parse=TRUE)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.