Reputation: 105
I need two or more lines of text on my y-axis title. However, the title is cut off if I have multiple lines. Anyway I can work around this?
ggplot(iris,aes(Sepal.Length, Sepal.Width)) +geom_line()+labs(y=expression(paste("line 1 \nline2")))
Upvotes: 2
Views: 2545
Reputation: 887118
We can use ylab
library(ggplot2)
ggplot(iris,aes(Sepal.Length, Sepal.Width)) +
geom_line()+
ylab(bquote("Mean Annual \nAir Temperature"~degree*"C")) +
theme(plot.margin = margin(1, 1, 0.5, 0.5, "cm"))
-output
Upvotes: 3
Reputation: 3660
Play with plot.margin
in theme
to change the whitespace around your plot
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_line() +
labs(y = expression(paste("line 1\nline2"))) +
theme(plot.margin = margin(1, 1, 1, 1, "cm")
)
Upvotes: 3