【发布时间】:2015-01-15 10:53:06
【问题描述】:
我有这个数据框
dput(C_Em_2000_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 = c(97004.1719086906, 10899.1747511239, 938738.864637841,
11024.7872260286, 129805.568347205, 778.178352715695, 28603.3785457348,
24333.5577048119)), .Names = c("V1", "V2", "V3"), row.names = c(NA,
-8L), class = "data.frame")
我想绘制当前绝对值的列 V3 的百分比值。到目前为止,我已经设法绘制了绝对值(见下文),但还需要绘制每个值的百分比(其中总值 = V3 列中值的总和)。
ggplot(C_Em_2000_Lat_Am, aes(x=V1, y = V3)) + geom_histogram(stat="identity", binwidth = 0.1)+
labs(x = "", y = "Carbon Emissions (T/year)") +
theme(axis.text=element_text(size=16),axis.title=element_text(size=20),
legend.title=element_text(size=20, face='bold'),legend.text=element_text(size=20), axis.line = element_line(colour = "black")) +
scale_fill_grey("grey50") + scale_y_continuous(limits=c(0,1000000))
有人可以帮我解决这个问题吗?谢谢
【问题讨论】:
标签: r ggplot2 percentage