0
我想添加一个线图到我的箱形图,次y轴,但我不能。该怎么办?请帮助如何添加线图使用次y轴,但相同的x轴的BOX图
代码为我的箱形图是:
library(ggplot2)
mydata<-read.csv("boxplot2.csv")
mydata$Class <- factor(mydata$Class,labels = c("1", "2", "3", "4", "5", "6"))
p10 <- ggplot(mydata, aes(x = mydata$Class, y = log(mydata$erosion))) +
geom_boxplot()
p10
p10 <- p10 +
scale_x_discrete(name = "Mean Annual Precipitation(mm/yr)") +
scale_y_continuous(name = "Log Average Erosion Rate(m/My)")
p10 <- ggplot(mydata, aes(x = mydata$Class, y = log(mydata$erosion))) +
geom_boxplot(varwidth=TRUE)
p10 <- p10 +
scale_x_discrete(name = "Mean Annual Precipitation(mm/yr)") +
scale_y_continuous(name = "Log Average Erosion Rate(m/My)")
我想类似的人物,但不是直方图,我将有箱线图
添加样本数据 %植被侵蚀等级 0 0.43 1 0 0.81 1 2 0.26 1 3 1.05 1 3 0.97 1 12.76 15.97 2 12.84 17.69 2 11.01 14.76 2 13.44 17.94 2 10.76 10.65 2 7.28 67.47 2 23 120.4 3 21 298.63 3 52 21.4 3 9 64.94 3 50 291.88 3 16 493.98 3 11 183.45 3
请提供可重复的前充足的(有一些子集或组成的数据)。你最终得到一个boxplot,因为你做了'geom_boxplot()' - 完全是什么问题? –
我想为我的箱形图添加一条线图。所以线条图将具有secdondary y轴,并且与我的箱形图相同的x轴 –
想法是创建与上图相同的东西,但不是直方图,而是想要箱形图,并且希望线图能够像它一样次y轴 –