我想放置条形,geom_bar以便 x 轴标签位于条形的左侧而不是中心
library(ggplot2)
df <- data.frame(
x = c(1,1,4,4,8,8),
y = c("A","B","A","B","A","B"),
z = c(10,5,20,2,8,4),
a = c(1,1,4,4,2,2)
)
ggplot(df,aes(x=x,y=z,fill=y,width=a)) +
geom_bar(stat="identity", position="identity", alpha=.6) +
scale_x_continuous(breaks=0:10)
Run Code Online (Sandbox Code Playgroud)
