R語(yǔ)言gganimate動(dòng)態(tài)圖(一)

library(ggplot2)
library(dplyr)
library(gganimate)
library(ggrepel)
ADHD %>% 
    ggplot(aes(x = Year, y = Value)) + 
    geom_point(aes(color = Location)) + 
    guides(size = F) + 
    scale_x_continuous(breaks = seq(1990, 2017, 3)) + 
    labs(title = 'Attention-defict/hyperactivity disorder\nBoth sexes, All ages',
         subtitle = 'Year:{current_frame}', 
         color = 'World Bank Regions',
         y = "DALYs  per  100,000") + 
    scale_color_brewer(palette = 'Set1') + 
    transition_manual(Year, cumulative = T) + 
    ggdark::dark_theme_bw() + 
    theme(panel.grid = element_blank())
dynamic-plot.gif
ADHD %>% 
    ggplot(aes(x = Year, y = Value)) + 
    geom_point(aes(color = Location, size = Value)) + 
    geom_label_repel(aes(x = Year, y= Value, label = Value)) + 
    guides(size = F) + 
    scale_x_continuous(breaks = seq(1990, 2017, 3)) + 
    labs(title = 'Attention-defict/hyperactivity disorder\nBoth sexes, All ages',
         subtitle = 'Year:{current_frame}', 
         color = 'World Bank Regions',
         y = "DALYs  per  100,000") + 
    scale_color_brewer(palette = 'Set1') + 
    transition_manual(Year) + 
    ggdark::dark_theme_bw() + 
    theme(panel.grid = element_blank())
dynamic-plot2.gif
iris %>% 
  ggplot(aes(Species, Sepal.Length, color = Species)) + 
  geom_violin(trim = F) + 
  geom_jitter() +  
  stat_boxplot(geom = 'errorbar', width = 0.2) + 
  geom_boxplot(aes(fill = Species), width = 0.4) + 
  stat_summary(fun.y = median, geom = 'point', size = rel(3), color = 'white') + 
  guides(color = F) + 
  labs(title = 'The Sepal.Length of Different Species') + 
  ggdark::dark_theme_bw() + 
  theme(panel.grid = element_blank()) + 
  scale_fill_brewer(palette = 'Set2') + 
  scale_color_brewer(palette = 'Set2') + 
  transition_manual(Species, cumulative = T) + 
 theme(plot.title = element_text(face = 4, size = rel(2)),
          axis.title = element_text(face = 4, size = rel(1.5)),
          axis.text = element_text(size = rel(1.2)))
dynamic-plot-3.gif
iris %>% 
  ggplot(aes(Species, Sepal.Length, color = Species)) + 
  geom_violin(fill = 'white', trim = F) + 
  stat_boxplot(geom = 'errorbar', width = 0.05, color = 'black') + 
  geom_boxplot(fill = 'black', color = 'black', width = 0.1) + 
  stat_summary(fun.y = median, geom = 'point', size = rel(3), color = 'white') + 
    geom_jitter() +  
  guides(color = F) + 
  labs(title = 'The Sepal.Length of Different Species') + 
  theme_bw() + 
  theme(panel.grid = element_blank()) + 
  scale_fill_brewer(palette = 'Set2') + 
  scale_color_brewer(palette = 'Set2') + 
  transition_manual(Species, cumulative = T) + 
  theme(plot.title = element_text(face = 4, size = rel(2)),
        axis.title = element_text(face = 4, size = rel(1.5)),
        axis.text = element_text(size = rel(1.2)))
dynamic-plot-4.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容