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: 
A few points:

As Nick noted, you should not be using `bd_mod$` to refer to variables inside of `aes()`. The whole point of specifying `data = bm_mod` is that is frees you from having to type `bm_mod$` over and over again.

Secondly, your attempt at setting `fill = pal` is somewhat confused. Specifying an aesthetic outside of `aes()` means you are *setting* it to a specific value, so that should only be done with a *single* value, e.g. `fill = "blue"`.

What you really want is a different fill for each x value, so you should be *mapping* fill to `country` and then setting the color scheme in `scale_fill_manual`.

When you ask questions like these, you should always provide a reproducible example. In this case, that would have been very easy, something like this:

```
df <- data.frame(x = letters,y = runif(26))

ggplot(df,aes(x = x,y = y)) + 
    geom_bar(aes(fill = x),stat = "identity",show_guide = FALSE) + 
    scale_fill_manual(values = colorRampPalette(brewer.pal(11,"RdYlGn"))(26))

```

I've used `colorRampPalette` to interpolate the colors in the brewer palette you would like to use.
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="")

```