简体   繁体   中英

R stacked bar plot with continuous scale

I'm trying to create a stacked bar plot to indicate when requests were made for resources on website. I would like to use a gradient legend to describe when the requests were made. How can I create a gradient legend, and would that be the right way to visualize this time domain data?

> head(livePostHit)
                               path       date hits
1     /2017/06/27/goog-fit-cal.html 2018/04/01    1
2  /2015/05/24/sqlite-tutorial.html 2018/04/01    1
3        /2016/11/07/coin-freq.html 2018/04/01    1
4     /2017/03/30/alpine-linux.html 2018/04/01    2
5 /2018/03/09/querySelectorAll.html 2018/04/01    1
6     /2017/11/24/fedora-27-rv.html 2018/04/01    1

> ggplot(livePostHit, aes(x = path, y = hits, fill = date)) +
  geom_bar(stat='identity') +
  theme(axis.text = element_text(angle=75, hjust = 1),
        legend.position = 'none')

I turned off the legend because there were too many groups for it to render correctly, but I would like to create like a gradient for the highest to the lowest.

图形

我只需要将日期设置为实际的日期类型而不是一个因素即可。

livePostHit$date <- as.Date(livePostHit$date)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM