10

13 色以上の ggplot2 のデフォルト スケールでは、高度な視覚的区別ができません。さらに、ブルワー スケールの最長は 12 のカテゴリ (Set3) で終了します。

13 以上のカテゴリで視覚的に役立つカラー スケールをお勧めできますか?

再現可能な例:

dat <- data.frame(value=rnorm(100),
category=sample(letters[1:13],100,replace=T),
other=sample(letters[1:5],100,replace=T))

# Default Scale
ggplot(dat, aes(other,value,color=category)) + 
geom_point(size=6) + 
coord_flip()

# Brewer Scale // notice the blank at the end!
ggplot(dat, aes(other,value,color=category)) + 
geom_point(size=6) + 
coord_flip() + 
scale_color_brewer(palette="Set3")

注:私の場合、ファセットはオプションではありません(クライアントはそれが好きではありません、図に進んでください)

4

1 に答える 1

9

colorRampPaletteand を使用しscale_colour_manualて、13 番目のカテゴリをごまかすことができます。

set3 <- colorRampPalette(brewer.pal('Set3',n=12))

ggplot(dat, aes(other,value,color=category)) + 
     geom_point(size=6) + 
     coord_flip() + 
     scale_color_manual(values = setNames(set3(13), levels(dat$category)))

必要な数値を高く設定しすぎると、色がうまく区別できなくなります。

于 2012-11-29T00:00:32.023 に答える