参数palette 控制着 scale_fill_brewer() 中的颜色选择: ggplot(mtcars,aes(factor(cyl),fill=factor(cyl)))+geom_bar()+scale_fill_brewer(palette="Set1") Palettes 在包 RColorBrewer 中 - 运行 display.brewer.all() 可以看到所有的选择: 有3 类调色板(palettes)- sequential,diverging,和 qualitative -...
使用ggplot2和RColorBrewer扩展调色板 此文为自己翻译,原文链接请看How to expand color palette with ggplot and RColorBrewer 直方图(histogram)和柱状图(bar)是数据分析展示的一部分。如果图是由R语言ggplot2包中函数geom_histogram()或者geom_bar()来制作,则柱状图看起来是这样的: library(ggplot2) ggplot(mtcars...
scale_fill_brewer(palette="Set2") 的确, length(unique(mtcars$hp)) 有 22 个唯一值,然而调色板 Set2 只有 8 中颜色。调色板中的颜色缺乏导致了ggplot如下的警告: Warning message: In RColorBrewer::brewer.pal(n, pal) : n too large, allowed maximum for palette Set2 is 8 Returning the palette...