Question: I currently have this barplot in R (created with `ggplot2`)
![enter image description here](https://i.stack.imgur.com/nuUa8.png)

I need to have it like this:

![enter image description here](https://i.stack.imgur.com/COLoY.png)

I tried to use RColorBrewer package, but it didn't work since the maximum amount of colours in the coresponding palette is 11. Any ideas?

```
pal <- brewer.pal(11,"RdYlGn")
ggplot(data = bm_mod, aes(x = bm_mod$country, y = bm_mod$V)) + 
  geom_bar(stat = "identity", colour = pal, fill = pal) + coord_flip() + 
  labs(y="Under/over valuation in %", x="")

```

Here is the data: [link](http://www.file-upload.net/download-8317296/bm_mod.csv.html)

Update:
I tried it again with this code:

```
ggplot(data = bm_mod, aes(x = country, y = V)) + 
  geom_bar(stat = "identity", fill = country, show_guide = FALSE) + 
  coord_flip() + scale_fill_manual(values = colorRampPalette(brewer.pal(11,"RdYlGn"))(nrow(bm_mod))) +
  labs(y="Under/over valuation in %", x="")

```

However the output looks pretty weird. Is it a problem with the brewer or another mistake?

![enter image description here](https://i.stack.imgur.com/aug77.png)

Answer: 
Here is an example with fake data. You need to specify `fill=V` in the aesthetics, as Henrik pointed out. And then you need a `scale_fill_XXXX` piece to specify which color scale you want to use.

```
require(ggplot2)

set.seed(100)
fake.data = data.frame(country = LETTERS, V = runif(26, -40, 40))
fake.data$country = factor(LETTERS, LETTERS[order(fake.data$V)]) # reorder factors

ggplot(data = fake.data, aes(x = country, y = V, fill = V)) +
  geom_bar(stat = "identity") +
  scale_fill_gradient2(low="red", mid="yellow", high="green") +
  coord_flip() +
  labs(y="Under/over valuation in %", x="")

```

Which produces the following plot:

![Colored Bar Chart](https://i.stack.imgur.com/BAgr2.jpg)
Would be enough to define 11 intervals and assign colors to them? Try this:

```
intervals <- cut(bm_mod$V, 11)
ggplot(data=bm_mod, aes(x=country, y=V)) + 
    geom_bar(stat="identity", colour=pal[intervals], fill=pal[intervals]) +
        coord_flip() + labs(y="Under/over valuation in %", x="")

```