spiralize常规的矩形图画成螺旋形
library(tidyverse)
#install.packages("spiralize")
library(spiralize)
library(ComplexHeatmap) #devtools::install_github("jokergoo/ComplexHeatmap")
library(cowplot)
library(magick)
#install.packages("tidytuesdayR")
#install.packages("rcartocolor")

library("rcartocolor")
library(tidytuesdayR)

tuesdata <- tidytuesdayR::tt_load('2021-12-07')
spiders <- tuesdata$spiders

unique(spiders$family)

#check most common family
spiders %>%
  group_by(family) %>% 
  summarise(n=n()) %>%
  arrange(desc(n))

#prep data
plot_data <- spiders %>% 
  filter(family == "Agelenidae") %>%
  select(year) %>% 
  group_by(year) %>%
  summarise(n=n()) 
plot_data

#colour function
col_fun = circlize::colorRamp2(seq(0,120,by=20), rcartocolor::carto_pal(n=7, name="Magenta"))

#spiral plot
spiral_initialize(xlim=c(1750, 2022), polar_lines_gp = gpar(col = "white", lty = 3))
spiral_track(ylim=c(0, 120), background_gp = gpar(col = NA, fill = "grey95"))
spiral_bars(plot_data$year, plot_data$n, 
            gp = gpar(fill = col_fun(plot_data$n), col = NA))

#add legend
lgd = Legend(title = "Number of publications", 
             at = c(0, 60, 120),
             col_fun = col_fun, 
             direction = "horizontal", 
             title_gp = gpar(fontsize = 12, fontfamily="sans", col = "#6c2167"),
             labels_gp = gpar(fontsize = 12, fontfamily="sans", col = "#6c2167"),
             legend_width = unit(60, "mm"),
             title_position = "topcenter")
draw(lgd, x = unit(0.5, "npc") , y=unit(-0.1, "npc"), 
     just = "center") 
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇