[英]Align bars and ticks with geom_bar
我的問題與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
為geom_bar選項,建議在這里 那么,如何對齊條以使其左邊框與刻度線對齊?
我正在使用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))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.