JK Lambert
JK Lambert

Reputation: 353

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:

enter image description here

Upvotes: 0

Views: 276

Answers (1)

JK Lambert
JK Lambert

Reputation: 353

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)```

Upvotes: 0

Related Questions