【发布时间】:2015-03-11 03:21:46
【问题描述】:
我用下面的脚本生成了这个图表。 但是如何下标 PM10 中的“10”、SO2 中的“2”和 NO2 中的“2”?
我试过levels(df$variable) <- c("PM[10]","SO[2]", "NO", "NO[2]"),但没有用。
有人可以帮忙吗?谢谢!
variable <- c("PM10","SO2","NO","NO2")
coef <- c(10,20,30,40)
coef_lb <- c(-5,10,23,27)
coef_ub <- c(20,39,39,50)
df <- as.data.frame(cbind(variable, as.numeric(coef),as.numeric(coef_lb),as.numeric(coef_ub)))
df$variable <- factor(df$variable,levels=c("PM10","SO2","NO","NO2"))
levels(df$variable) <- c("PM[10]","SO[2]", "NO", "NO[2]")
library(ggplot2)
#ggplot 95%CI
BWplot <- ggplot(data=df,aes(x=variable,y=coef))
BWplot <- BWplot + geom_pointrange(aes(ymin=coef_lb,ymax=coef_ub))
BWplot <- BWplot + geom_point()
BWplot <- BWplot + scale_y_continuous(limits=c(-110, 110),breaks=seq(-100, 100, by = 20))
BWplot <- BWplot + xlab("Air pollutant")
BWplot <- BWplot + ylab("Mean change")
BWplot <- BWplot + geom_hline(yintercept=0,alpha=0.5)
BWplot
【问题讨论】:
标签: r ggplot2 axis-labels