6

I have a simple bar graph in ggplot2. I am using the "grey" scale for my bars; the default order is darkest to lightest from left to right. Here's what my code looks like:

  ggplot.3plus<-ggplot(summary.3plus, aes(x=sp1, y=fract.mean, fill=age.cat)) + 
  geom_bar(position=position_dodge())+ coord_cartesian(ylim = c(1, 1.175))+
  geom_errorbar(aes(ymin=fract.mean-se, ymax=fract.mean+se),
                width=.2,                    # Width of the error bars
                position=position_dodge(.9))
  ggplot.3plus<-ggplot.3plus+scale_fill_grey()

I would like to change the color order of the greys to lightest to darkest from left to right, while keeping the bars themselves in the same order. The code I'm using to reverse the order of the color ramp doesn't seem to be working.

Luke
  • 4,769
  • 5
  • 28
  • 36

2 Answers2

13

It would be easier with a reproducible example, but what about:

y + scale_fill_grey(start=0.8, end=0.2)
csgillespie
  • 59,189
  • 14
  • 150
  • 185
-1

you can try + scale_y_reverse()