Assigning continuous fill color to geom_bar

后端 未结 1 1560
傲寒
傲寒 2021-01-24 01:36

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

相关标签:
1条回答
  • 2021-01-24 02:13

    You haven't assigned the fill aesthetic to anything: aes(month, count, fill = count) should do the trick.

    Complete code:

    ggplot(userData, aes(month, count, fill = count)) +
        geom_bar(stat = "identity") +
        scale_x_date() + 
        scale_fill_continuous(low="blue", high="red") +
        labs(x= "Time", y="Count")
    

    (limits are probably useless now, but feel free to add them back)

    0 讨论(0)
提交回复
热议问题