【发布时间】:2019-06-03 05:36:37
【问题描述】:
对于主要的 y 轴和 x 轴,我有通用标题,例如“坦克的比率”和“计数”。我想要第二行标签,在其中指定比率和计数。例如。在“坦克的比率”下方,我想要“# in water/# in sand”以较小的字体但沿 y 轴。对于 x 轴也是如此。 这是基本代码
data <- data.frame(set = c(1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4), density = c(1, 3, 3, 1, 3, 1, 1, 1, 3, 3, 1, 3), counts = c(100, 2, 3, 76, 33, 12, 44, 13, 54, 36, 65, 1), ratio = c(1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 90, 1))
library(ggplot2)
ggplot(data, aes(x = counts, y = ratio)) +
geom_point() +
ylab("Tank's Ratio") +
xlab("Counts")
【问题讨论】:
-
我不确定是否要调整字体大小,但您可以在 ylab 中添加换行符 (\n)。试试
ggplot(data,aes(x=counts, y=ratio)) + geom_point() +ylab("Tank's Ratio \n#in water/# in sand") + xlab("Counts")