使用ggplot绘制直方图并更改y轴的比例范围

时间:2015-01-14 14:10:33

标签: r ggplot2 histogram

我想用ggplot绘制直方图。以下是我的数据框:

dput(EF_Lat_Am)
structure(list(V1 = structure(c(4L, 3L, 5L, 6L, 1L, 2L, 7L, 8L
), .Label = c("Crop Agriculture", "Mining", "Mixed Agriculture", 
"Other land use", "Pasture", "Tree crops", "Urban", "Water"), class = "factor"), 
    V2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "Emission Factor", class = "factor"), 
    V3 = structure(c(3L, 1L, 6L, 5L, 4L, 2L, 8L, 7L), .Label = c("1.38363721347693", 
    "3", "3.03607405378543", "3.35324124601422", "3.52527326710239", 
    "4.16610826572262", "4.19965318720433", "6.5336625792114"
    ), class = "factor")), .Names = c("V1", "V2", "V3"), row.names = c(NA, 
-8L), class = "data.frame")

我已设法使用下面的代码行绘制直方图。但是,我希望我的y轴的比例范围从0到10,我无法使用scale_y_discretescale_y_continuous函数来完成。

ggplot(EF_Lat_Am, aes(x=V1, y = V3)) + geom_histogram(stat="identity", binwidth = 0.1)+
  labs(x = "", y = "EF (T/ha/year)") +
  theme(axis.text=element_text(size=20),axis.title=element_text(size=15), 
        legend.title=element_text(size=20, face='bold'),legend.text=element_text(size=20), axis.line = element_line(colour = "black")) +
  scale_fill_grey("grey50")

有人可以帮我解决这个问题吗?感谢

0 个答案:

没有答案