RR可视化小本本R plot

R|可视化|morris配色

2021-02-18  本文已影响0人  高大石头

William Morris的方案按照世界名画的配色进行选取,特别适合在sci文章中进行展示。

安装

#devtools::install_github("cshoggard/morris")

所有的颜色都用magick和imager包进行提取,下面是William Morris最著名的6个方案:

Strawberry Thief (1883)

scales::show_col(morris:::strawberry_palette)
image.png

Trellis(1864)

Trellis

scales::show_col(morris:::trellis_palette)

Holland Park (1883)

Holland Park

scales::show_col(morris:::holland_palette)

Peacock and Dragons (1878)

Peacock and Dragons

scales::show_col(morris:::peacock_palette)

Embroidery with Flowers and Leaves (1885-1895)

Embroidery

scales::show_col(morris:::flowers_palette)

Acanthus(1875)

Acanthus

scales::show_col(morris:::acanthus_palette)
image.png

例子

示例数据集中,iris在R中应用较多(correlation,regression,classification),titanic在Python中应用更为广泛。下面用另一个数据集penguins:

penguins和penguins_raw都包含在palmerpenguins包。是由Dr. Kristen Gorman收集的 the Palmer Station, Antarctica LTER企鹅数据信息。

#library(extrafont) 
#loadfonts(device = "win") #应用新的字体
library(morris)
p_load(palmerpenguins)
glimpse(penguins)
## Rows: 344
## Columns: 8
## $ species           <fct> Adelie, Adelie, Adelie, Adelie, Adelie, Adelie, A...
## $ island            <fct> Torgersen, Torgersen, Torgersen, Torgersen, Torge...
## $ bill_length_mm    <dbl> 39.1, 39.5, 40.3, NA, 36.7, 39.3, 38.9, 39.2, 34....
## $ bill_depth_mm     <dbl> 18.7, 17.4, 18.0, NA, 19.3, 20.6, 17.8, 19.6, 18....
## $ flipper_length_mm <int> 181, 186, 195, NA, 193, 190, 181, 195, 193, 190, ...
## $ body_mass_g       <int> 3750, 3800, 3250, NA, 3450, 3650, 3625, 4675, 347...
## $ sex               <fct> male, female, female, NA, female, male, female, m...
## $ year              <int> 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2...

主要包含8列企鹅的信息:

image.png

企鹅特征

penguins %>% 
  ggplot(aes(flipper_length_mm,body_mass_g,shape=species,colour=species))+
  geom_point(size=3)+
  scale_color_flowers()+
  labs(title = "Penguin Mass vs. Flipper Length",
       x="Flipper Length (mm)",
       y="Body Mass (g)",
       shape="Species",
       colour="Species")+
  theme(plot.title = element_text(size = 18,hjust = 0.5,margin = margin(0,0,20,0)))
image.png

参考内容

https://github.com/CSHoggard/morris

Gorman KB, Williams TD, Fraser WR (2014). Ecological sexual dimorphism and environmental variability within a community of Antarctic penguins (genus Pygoscelis). PLoS ONE 9(3):e90081. https://doi.org/10.1371/journal.pone.0090081

https://github.com/allisonhorst/palmerpenguins

上一篇 下一篇

猜你喜欢

热点阅读