Bar color according to height in ggplot2
<p>How can I change the color of bars in a bar-chart to be in a scale according to its height? Here's an example:</p>

<pre><code>library(ggplot2)
year = c(2000,2000,2001,2001,2001,2002,2003,2003,2004,2004,2004,2004,2005)
df = data.frame(year)

ggplot(df) + geom_bar(aes(year,fill=year))
</code></pre>

<p>I need the colors to be in a scale according to the count of each year (light blue for years with a low counts and dark blue for higher counts, for example).</p>

<p>I could do it by using the counts as the data frame (2000;2, 2001;3, etc.), but that would require a lot of work in other parts of my code, so I'd rather keep the data in this format.</p>