我的问题与stibu 的这个答案有关。我正在使用geom_bar
并且我正在尝试将 x 轴刻度之间的条形居中(请参阅答案的第二张图)。
下面是一个例子:
grp<-letters[1:13]
count<-c(38,591,549,487,419,363,276,276,164,68,31,10,5)
data<-data.frame(grp,count)
ggplot(data,aes(x=grp,y=count))+geom_bar(stat="identity")
这给出了以下内容:
boundary
或center
选项那么如何对齐条形以便它们的左边框与刻度对齐?
我使用的是 R 版本 3.4.0 和 RStudio 1.0.143。
那是你要的吗 ?
require(ggplot2)
grp<-letters[1:13]
count<-c(38,591,549,487,419,363,276,276,164,68,31,10,5)
data<-data.frame(grp,count)
ggplot(data,aes(x=grp,y=count))+
geom_bar(stat="identity",
width = 0.9,
position = position_nudge(x = 0.5))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句