RColorBrewer  16進数コードまとめ


色の16進数表記をいちいち出すのがめんどうなので、メモ

の前に

### RColor Brewerでよく使うコマンド
```
library(RColorBrewer)

#全てのカラーパレットの表示
display.brewer.all(n = NULL, 
                   type = "all", 
                   select = NULL,
                   colorblindFriendly = FALSE)
##これだけでも良い
display.brewer.all()

#１つのカラーパレットの表示
display.brewer.pal(n = 8, name = 'Dark2')

#色の16進数表記を抽出
##nは3以上でないと（なぜか）エラーが出る
brewer.pal(n = ４, name = "Dark2")

##output
##[1] "#1B9E77" "#D95F02" "#7570B3" "#E7298A"
```

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/40b600f5-a2ad-89af-de63-756233ccf3e9.png)


### 16進数表記一覧
色分けでよく使うセットのみとなっています。

#### Set1
```
> brewer.pal(n = 8, name = "Set1")
[1] "#E41A1C" "#377EB8" "#4DAF4A" "#984EA3" "#FF7F00" "#FFFF33"
[7] "#A65628" "#F781BF"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/1dce153c-25cc-f1c3-7157-0f890aba7c3f.png)


#### Set2
```
> brewer.pal(n = 8, name = "Set2")
[1] "#66C2A5" "#FC8D62" "#8DA0CB" "#E78AC3" "#A6D854" "#FFD92F"
[7] "#E5C494" "#B3B3B3"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/dbebee8f-0e2b-c8b3-b2c6-252836b3ba9e.png)


#### Set3
```
> brewer.pal(n = 12, name = "Set3")
 [1] "#8DD3C7" "#FFFFB3" "#BEBADA" "#FB8072" "#80B1D3" "#FDB462"
 [7] "#B3DE69" "#FCCDE5" "#D9D9D9" "#BC80BD" "#CCEBC5" "#FFED6F"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/cfd3f2f5-113b-6d00-185d-feeca57b1493.png)


#### Pastel1
```
> brewer.pal(n = 9, name = "Pastel1")
[1] "#FBB4AE" "#B3CDE3" "#CCEBC5" "#DECBE4" "#FED9A6" "#FFFFCC"
[7] "#E5D8BD" "#FDDAEC" "#F2F2F2"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/0fa6807d-9487-085b-9ec7-d8a07bcd2f16.png)


#### Pastel2
```
> brewer.pal(n = 8, name = "Pastel2")
[1] "#B3E2CD" "#FDCDAC" "#CBD5E8" "#F4CAE4" "#E6F5C9" "#FFF2AE"
[7] "#F1E2CC" "#CCCCCC"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/49d2fa21-fd04-c9b1-38e5-57e6e4d75e12.png)


#### Paired
```
> brewer.pal(n = 12, name = "Paired")
 [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C"
 [7] "#FDBF6F" "#FF7F00" "#CAB2D6" "#6A3D9A" "#FFFF99" "#B15928"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/0fab6cd1-c402-6bd5-2f7d-ce93b38c3d21.png)


#### Dark2
```
> brewer.pal(n = 8, name = "Dark2")
[1] "#1B9E77" "#D95F02" "#7570B3" "#E7298A" "#66A61E" "#E6AB02"
[7] "#A6761D" "#666666"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/d7fb4f50-85b2-eabd-e4ba-58b708d94e09.png)


#### Accent
```
[1] "#7FC97F" "#BEAED4" "#FDC086" "#FFFF99" "#386CB0" "#F0027F"
[7] "#BF5B17" "#666666"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/dfc94b00-d625-9965-53ca-d41d9dcf0d3d.png)

#### Spectral
```
> brewer.pal(n = 11, name = "Spectral")
 [1] "#9E0142" "#D53E4F" "#F46D43" "#FDAE61" "#FEE08B" "#FFFFBF"
 [7] "#E6F598" "#ABDDA4" "#66C2A5" "#3288BD" "#5E4FA2"
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/605546/f4f06515-b54c-86fb-9ed7-db77e56fe390.png)


### RColorBrewer以外の色が欲しい場合

* Rのカラーパレットをまとめたサイト：[TOP R COLOR PALETTES TO KNOW FOR GREAT DATA VISUALIZATION](https://www.datanovia.com/en/blog/top-r-color-palettes-to-know-for-great-data-visualization/)
* [色の名前で指定可能な色一覧](https://cpb-us-e1.wpmucdn.com/sites.ucsc.edu/dist/d/276/files/2015/10/colorbynames.png)
* [16進法表記一覧](https://www.pagetutor.com/hosted_sample1/bgcolors1536.html)
※下２つは[Colors in R](https://derekogle.com/NCGraphing/resources/colors) 参照

また、googleで[Color code picker](https://g.co/kgs/NTV4Xy)と検索すると選んだ色のコードが取得できるようです！