How to extract the fill colours from a ggplot object?

前端 未结 1 1126
遥遥无期
遥遥无期 2020-11-29 22:54

I am trying to write some automated unit tests for a series of functions that generates ggplot graphics.

For example, I want to set a specific colour sc

相关标签:
1条回答
  • 2020-11-29 23:19

    Try building the plot,

    g <- ggplot_build(p)
    unique(g$data[[1]]["fill"])
    
          fill
    1  #1B9E77
    16 #D95F02
    28 #7570B3
    
    0 讨论(0)
提交回复
热议问题