Multicolor titles with ggplot2 for R

前端 未结 2 1027
春和景丽
春和景丽 2020-12-18 22:27

I was trying to implement multicolor texts as shown here:

multicolor text on chart

which referenced this:

multicolor text in R

This is what I

2条回答
  •  孤城傲影
    2020-12-18 22:49

    A possible strategy wrapping the words in a dummy table,

    library(gridExtra)
    library(grid)
    library(ggplot2)
    title = c('Concentration of ','affluence',' and ','poverty',' nationwide')
    colors = c('black', '#EEB422','black', '#238E68','black')
    
    grid.arrange(ggplot(), 
                 top = tableGrob(t(title), 
                                 theme=ttheme_minimal(padding=unit(c(0,2),'mm'),
                                                      base_colour = colors)))
    

    enter image description here

提交回复
热议问题