R颜色-许多独特的颜色仍然很漂亮 [英] R colors - many distinctive colors that are still pretty

查看:200
本文介绍了R颜色-许多独特的颜色仍然很漂亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,如果您对R中的一些颜色有一些技巧,可以使图表看起来仍然不错.

I am curious if you have some tips on colour-brewing in R, for many distinctive colours, in a way that the graph is still good-looking.

对于堆叠区域图,我需要大量独特的颜色(至少24种,可能甚至需要更多,〜50种)(因此,如果没有热图,则渐变色将不起作用).我遇到了虹彩,有非常漂亮的调色板,也适用于色盲人群.不幸的是,那些没有足够的颜色在我的情节上仍然可以区分.

I need a fair amount of distinctive colours (24 at least, probably will need even more, ~50) for stacked area plots (so not heatmaps, gradual colours would not work). I came across viridis, that has really pretty palettes, which also work for colourblind people. Unfortunatelly those do not have enough colours to still be distinguishable on my plots.

在Google上花费了一些时间之后,我也查看了其他软件包/调色板(这篇文章特别酷:

I looked into other packages/palettes too, after spending some time on google (this post was particularly cool: How to generate a number of most distinctive colors in R?), but did not find anything that had enough colours AND still looked good.

当需要24种以上颜色时,如何使图形看起来好看?

How do you make a graph good looking when 24+ colours are needed?

推荐答案

您可以尝试 randomcoloR (最多40种不同的颜色)或 pals (最多26种颜色).

You can try either randomcoloR (up to 40 distinct colors) or pals (up to 26 colors).

# k: number of colors (>= 1). May be ineffective for k > 40.
library(randomcoloR)
nColor <- 40
myColor <- randomcoloR::distinctColorPalette(k = 40)
pie(rep(1, nColor), col = myColor)

# https://cran.r-project.org/web/packages/pals/vignettes/pals_examples.html
library(pals)
labs = c('alphabet', 'alphabet2', 'glasbey', 'kelly', 'polychrome')
op = par(mar = c(0, 5, 3, 1))
pal.bands(alphabet(), alphabet2(), glasbey(), kelly(), polychrome(), 
          labels = labs, show.names = FALSE)

reprex软件包(v0.2.0)创建于2018-05-13.

Created on 2018-05-13 by the reprex package (v0.2.0).

这篇关于R颜色-许多独特的颜色仍然很漂亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆