好色之徒

2020-03-13南丁格尔玫瑰花图(新冠疫情)

2020-03-13  本文已影响0人  iColors

用的是R 包 nCov2019 (https://github.com/GuangchuangYu/nCov2019).

安装

library('remotes')
remotes::install_github("GuangchuangYu/nCov2019", dependencies = TRUE)

南丁格尔玫瑰花图

require(nCov2019)
y <- load_nCov2019(lang = 'en', source='github')
d = y['global']

require(dplyr)
dd <- filter(d, time == time(y)) %>% 
    arrange(desc(cum_confirm)) 

dd = dd[1:40, ]
dd$country = factor(dd$country, levels=dd$country)

dd$angle = 1:40 * 360/40
require(ggplot2)
ggplot(dd, aes(country, cum_confirm, fill=cum_confirm)) + 
    geom_col(width=1, color='grey90') + 
    geom_col(aes(y=I(7)), width=1, fill='grey90', alpha = .2) +       
    geom_col(aes(y=I(5)), width=1, fill='grey90', alpha = .2) +    
    geom_col(aes(y=I(3)), width=1, fill = "white") +
    scale_y_log10() + 
    scale_fill_gradientn(colors=c("darkgreen", "orange", "red","firebrick","darkred"), trans="log") + 
    geom_text(aes(label=paste(country, cum_confirm, sep="\n"), 
                  y = cum_confirm *.8, angle=angle), 
              data=function(d) d[d$cum_confirm > 100,], 
              size=3, color = "white", fontface="bold", vjust=1)  + 
    geom_text(aes(label=paste0(cum_confirm, " ",country), 
                  y = max(cum_confirm) * 2, angle=angle+90), 
              data=function(d) d[d$cum_confirm < 100,], 
              size=3, vjust=0) + 
    coord_polar(direction=-1) + 
    theme_void() + 
    theme(legend.position="none")
image.png

与人民日报的原图比还有差距:
(1)文字大小是统一的,不是确诊率高就文字大;
(2)文字角度排布是固定的;
(3)颜色已经比较接近了;
(4)柱子的高度差异没有人民日报大。

image.png

大家有好的建议欢迎留言!!!

上一篇下一篇

猜你喜欢

热点阅读