我正在尝试模拟类似图片的情节,如何使我的情节的白色文本更具可读性,如下面的图片。
我模拟的图片:
我的情节:
我的代码:
# remotes::install_github("GuangchuangYu/nCov2019")
# get COVID-19 data
require(nCov2019)
y = load_nCov2019(lang = 'zh')
d = y['global']
# filter data
require(dplyr)
dd <- filter(d,time == time(y) & country != '中国') %>%
arrange(desc(cum_confirm))
dd = dd[1:40,]
dd$country = factor(dd$country,levels = dd$country)
dd$angle = 1:40*360/40
# plot data
require(ggplot2)
ggplot(dd,aes(country,cum_confirm,fill = cum_confirm)) +
geom_col(width = 1,color = 'grey90') +
geom_col(aes(y = I(2)),width = 1,fill = 'white') +
scale_y_log10()+
scale_fill_gradientn(colours = c('darkgreen','green','orange','firebrick','red'),trans = 'log') +
geom_text(aes(label = paste(country,sep = '\n'),y = cum_confirm*0.8,angle = angle),data = function(d) d[d$cum_confirm > 100,],color = 'white',fontface = 'bold',vjust = 1)+
geom_text(aes(label = paste0(cum_confirm," ",country),y = cum_confirm*5,angle = angle + 90),data = function(d) d[d$cum_confirm < 100,vjust = 0) +
coord_polar(direction = -1) +
theme_void()+
theme(legend.position = "none")