【发布时间】:2021-11-01 11:41:03
【问题描述】:
在“treemapify”中,我使用函数“paste0”将三个变量组合为标签,现在我想分别更改字体颜色和大小(如下代码中的注释)。 任何人都可以帮忙吗?谢谢!
library(ggplot2)
library(treemapify)
library(formattable)
plot_data <- data.frame(
region=c("a","b","c","d","e","f"),
amount=c(3,2,1,7,2,4),
increase=c(0.5,0.1,0.7,0.4,0.3,0.9))
plot_data %>% ggplot(aes(area=amount,fill=region,
label=paste0(region, #' want the font color 'darkblue'
'\n',
comma(amount,1), # want the font color 'grey60'
'\n',
percent(increase,1) # want the font color 'white'
)))+
geom_treemap()+geom_treemap_text()
【问题讨论】: