3

I am still struggling with correct labels of my plots. I managed to get this to work.

df <-data.frame(a=seq(1,20),b=seq(1,20))
ggplot(df, aes(x = a, y = b)) + geom_point() +
  ylab(expression(paste(CH[4]~" formation rate"~"(",mu, mol, day^{-1},")")))

What it is missing is the operator sign " * " between mumol and day^-1. It should look like this: enter image description here Thank you for your help.

3
  • Is CH[4]~" formation rate"~"(",mu, mol%*%day^{-1},")" not what you're looking for? Commented Jan 10, 2017 at 11:11
  • thank you for your input. Your snippet produces: imgur.com/41mtmwZ Definitely progress, but not quite there. Commented Jan 10, 2017 at 11:50
  • 1
    is this what you need ylab(expression(CH[4]~formation~rate~(mu*mol~'*'~day^{-1}))) Commented Jan 10, 2017 at 12:40

1 Answer 1

6

I prefer not to use the paste style for expressions but to use ~ and * to separate terms with or without a space respectively. If you want an *, put it in quotes.

ggplot(df, aes(x = a, y = b)) + 
  geom_point() + 
  ylab(expression(CH[4]~formation~rate~(mu*mol~'*'~day^{-1}))) 
Sign up to request clarification or add additional context in comments.

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.