I am trying to add a superscript to my Y-axis title on ggplot but can't get it to work. I looked at similar questions on here such as this one, but I think that because I have another symbol within the same parenthesis it is not working.
I need my Y-axis title label to be: Total Density (individuals ∙ L⁻¹)
I have tried the following:
1.
labs(y="Total Density (individuals ∙"~L^-1)
which almost works but I can't figure out how to add the closing parenthesis to this
2.
labs(y="Total Density"~(individuals ∙ L^-1))
gives an error
3.
labs(y="Total Density"~(individuals~L^-1))
this works, except when I try to add the multiplication ∙ symbol
4.
ylab("Total Density" "(individuals p "~L^-1*")")
this also gives an error
5.
ylab("Total Density" (~individuals ∙ L^-1))
gives an error
6.
labs(y=expression(Total~Density~(~individuals~∙~L^{-1})))
error
7.
labs(y=expression(Total~Density~(individuals ∙ L^-1)))
error
8.
ylab(bquote('Total Density (individuals ∙ L^-1)'))
not putting the "-1" as superscript
9.
ylab(bquote('Total Density (individuals ∙ L'^-1))
almost works but again, can't figure out how to add the closing parenthesis to this
I feel like I am close to get what I need, but no matter what I do I can't get it to work. Is there another way I should be typing in the multiplication sign to get this to work? I basically just copied/pasted "∙" to be there.
You can use bquote(Total~density~(Individuals%.%L^-1))
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
labs(y = bquote(Total~density~(Individuals%.%L^-1)))