I am generating a bar chart from data that is in the following format:
count | month
------|-----------
1000 | 2012-01-01
10000 | 2012-02-01
I am trying to assign continuous colors to my bar chart. I want a gradient of colors to be used as the fill color of the bars.
I am trying this:
ggplot(userData, aes(month, count)) +
geom_bar(stat = "identity") +
scale_x_date() +
# scale_fill_gradient(low="blue", high="red") +
scale_fill_continuous(low="blue", high="red", limits=c(0,6500000)) +
labs(x= "Time", y="Count")
However, I am not getting the desired result and the bars in the chart still stays gray as can be seen below:
I have tried with both scale_fill_continuous
, and scale_fill_gradient
, but without success.
I am not sure exactly what I am missing here.
You haven't assigned the fill aesthetic to anything:
aes(month, count, fill = count)
should do the trick.Complete code:
(limits are probably useless now, but feel free to add them back)