美文网首页绘图技巧数据分析
2019-09-27用ggforce给ggplot图上画圈圈

2019-09-27用ggforce给ggplot图上画圈圈

作者: iColors | 来源:发表于2019-09-27 21:33 被阅读0次

    by Edgar Ruiz 原文链接

    ggplot图形的增强包ggforce,实现强调部分数据的功能。

    library(tidyverse)
    library(ggforce)
    library(nycflights13)
    
    p <- airports %>%
      filter(lon < 0, tzone != "\\N") %>%
      ggplot(aes(lon, lat, color = tzone)) + 
      geom_point(show.legend = FALSE)  
    

    给图上添各种圈

    p +  geom_mark_rect() 
    

    image.png
    p + 
      geom_mark_rect(aes(label = tzone)) 
    
    image.png
    p + 
      geom_mark_rect(aes(label = tzone), show.legend = FALSE) +
      theme_void() 
    
    image.png
    p + 
      geom_mark_hull(aes(label = tzone)) +
      theme_void() 
    
    image.png
    p + 
      geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE) +
      theme_void() 
    
    image.png
    p + 
      geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE, expand = unit(3, "mm")) +
      theme_void() 
    
    image.png
    p + 
      geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE, expand = unit(3, "mm")) +
      theme_no_axes() 
    
    image.png
    p +
      geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE, expand = unit(3, "mm")) +
      theme_no_axes() +
      facet_zoom(x = tzone == "America/Los_Angeles")
    
    image.png

    相关文章

      网友评论

        本文标题:2019-09-27用ggforce给ggplot图上画圈圈

        本文链接:https://www.haomeiwen.com/subject/zvgauctx.html