简体   繁体   中英

Color histogram bars using stat_bin ggplot

I would like to change the fill and color of my histogram bars, However the current approach does not work, I am using the following fill and color:

ggplot(dfAllCounts, aes(x=months)) +
  stat_bin(binwidth=6, geom="text", aes(label=after_stat(count)), vjust=-1, fill="#d2aa47", color = '#163B8B')

However, the actual plot is not displayed propertly:

在此处输入图像描述

Done: Fixed with this:

br <- seq(0, 178, 10)
ggplot(dfAllCounts, aes(x=months)) +
  stat_bin(binwidth=6, fill="#d2aa47", color = '#163B8B', size = .8, alpha = 0.3) +
  stat_bin(binwidth=6, geom="text", aes(label=..count..), vjust=-1) +
  ylim(c(0, 175)) + 
  scale_x_continuous(breaks = br)```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM