ggplot2 - y 轴标题上的两行或多行
ggplot2 - two or more lines on y axis title
我的 y-axis 标题需要两行或更多行文字。但是,如果我有多行,标题会被截断。无论如何我可以解决这个问题?
ggplot(iris,aes(Sepal.Length, Sepal.Width)) +geom_line()+labs(y=expression(paste("line 1 \nline2")))
在 theme
中使用 plot.margin
来更改情节周围的空白区域
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")
)
我们可以使用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"))
-输出
我的 y-axis 标题需要两行或更多行文字。但是,如果我有多行,标题会被截断。无论如何我可以解决这个问题?
ggplot(iris,aes(Sepal.Length, Sepal.Width)) +geom_line()+labs(y=expression(paste("line 1 \nline2")))
在 theme
中使用 plot.margin
来更改情节周围的空白区域
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")
)
我们可以使用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"))
-输出