ggplot2统计编程语言英语Computational statisticsR的一个数据可视化绘图包。ggplot2由哈德利·威克漢姆在2005年创造。它具现了利兰·威尔金森英语Leland Wilkinson所著《图标的语法 — 一个数据可视化通用框架》(Grammar of Graphics — a general scheme for data visualization)中将图形分解为语素(如尺度、图层)的思想。ggplot2可以作为R语言基础绘图包的替代,同时ggplot2预设有多种印刷及网页尺寸。自2005年以来,ggplot2已经发展成为最受欢迎的R包之一。[3][4]

ggplot2
原作者哈德利·威克漢姆, Winston Chang
当前版本
  • 3.5.0 (2024年2月23日;穩定版本)[1]
編輯維基數據鏈接
源代码库 編輯維基數據鏈接
编程语言R
许可协议GPLv2[2]
网站ggplot2.org

ggplot2
ggplot2
Base graphics
基本绘图包
使用基本绘图包与 ggplot2 预设参数绘制的简单散点图

更新 编辑

ggplot2在2012年3月2日发布了0.9.0版本。本次更新提供了内部组织、尺度构建和图层等方面的众多更新。[5]

2014年2月25日,Hadley Wickham正式宣布「ggplot2正转至维护模式。意味着ggplot2不会再添加新的功能,不过我们会继续修复重要故障,并考虑增加由推送请求新提交的特性。为纪念这显著的里程碑,ggplot2的下一个版本将会是1.0.0」。[5]

ggplot2在2015年12月21日发布了2.0.0版本。在版本公告中宣布了“ggplot2现在拥有官方扩展机制。这表示其他人现在可以轻松创造他们的统计方式、几何图形和位置方案,并在其他包中提供”。[6]

同其他绘图包的比较 编辑

较R基础绘图包而言,ggplot2允许用户在更抽象的层面上增加、删除或转换图表中的元素。[7] 这种抽象化的代价是执行速度。ggplot2 较 lattice 绘图包而言更耗时。[8]

R基础绘图包使用“纸笔模型”占据绘图设备产生了一个潜在的限制:解释器产生的不同图表元素的图形输出直接添加到绘图设备上,而不是分别添加。 [9][10]在这个层面上,它同lattice包是相似的。相对的,Wickham声称ggplot2继承了更多威尔金森的图形规范化模型[11]正如此,ggplot2允许绘图更加的模块化:相同的内部数据可以转化为很多不同的尺寸及图层。[12][13]

qplot()函数的变量及预设同基础绘图函数plot() 较为相似,可以方便地绘制基础图表。[14][15] ggplot()函数将语法元素直接暴露给用户,可以绘制更加复杂的图表[16]

相关项目 编辑

  • ggplot for Python[17]
  • Plotly - 在线交互 ggplot2 绘图站[18]
  • gramm,一个由 ggplot2 提供灵感的 Matlab 绘图工具[19]

参考文献 编辑

  1. ^ Release 3.5.0. 2024年2月23日 [2024年3月22日]. 
  2. ^ Wickham, Hadley; Chang, Winston; RStudio. ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. 2016-12-30 [2017-10-20]. (原始内容存档于2021-01-18) –通过R-Packages. 
  3. ^ Wickham, Hadley. ggplot2: Elegant Graphics for Data Analysis. Journal of Statistical Software. July 2010, 35 (1) [2017-10-20]. (原始内容存档于2015-02-01). 
  4. ^ Wilkinson, Leland. ggplot2: Elegant Graphics for Data Analysis by WICKHAM, H. Biometrics. June 2011, 67 (2): 678–679. doi:10.1111/j.1541-0420.2011.01616.x. 
  5. ^ 5.0 5.1 ggplot2 Development Team. Changes and Additions to ggplot2-0.9.0 (PDF). [2017-10-20]. (原始内容 (PDF)存档于2015-01-26). 
  6. ^ ggplot 2.0.0 | RStudio Blog. blog.rstudio.org. [2017-10-21]. (原始内容存档于2017-04-27) (美国英语). 
  7. ^ Smith, David. Create beautiful statistical graphics with ggplot2. Revolutions. Revolution Analytics英语Revolution Analytics. [2011-07-11]. (原始内容存档于2011-09-13). 
  8. ^ ggplot2 Version of Figures in “Lattice: Multivariate Data Visualization with R” (Final Part). 2009-08-25 [2017-10-20]. (原始内容存档于2020-11-23). 
  9. ^ Wickham, Hadley. ggplot2: Elegant Graphics for Data Analysis. Springer. 2009: 5. ISBN 978-0-387-98140-6. 
  10. ^ Murrell, Paul. R Graphics. Wiley Interdisciplinary Reviews: Computational Statistics. August 2009, 1 (2): 216–220. doi:10.1002/wics.22. 
  11. ^ Sarkar, Deepayan. Lattice: multivariate data visualization with R. Springer. 2008: xi. ISBN 978-0-387-75968-5. 
  12. ^ Teetor, Paul. R Cookbook. O'Reilly. 2011: 223. ISBN 978-0-596-80915-7. 
  13. ^ Wickham, Hadley. A Layered Grammar of Graphics. Journal of Computational and Graphical Statistics. March 2010, 19 (1): 3–28. doi:10.1198/jcgs.2009.07098. 
  14. ^ R Development Core Team. R: A language and environment for statistical computing. Vienna, Austria: R Foundation for Statistical Computing. 2011 [2020-09-25]. ISBN 3-900051-07-0. (原始内容存档于2011-03-05). 
  15. ^ Ginestet, Cedric. ggplot2: Elegant Graphics for Data Analysis. Journal of the Royal Statistical Society, Series A. January 2011, 174 (1): 245–246. doi:10.1111/j.1467-985X.2010.00676_9.x. 
  16. ^ Muenchen, Robert A.; Hilbe, Joseph M. Graphics with ggplot2. R for STATA Users. Springer. ISBN 978-1-4419-1317-3. doi:10.1007/978-1-4419-1318-0_16. 
  17. ^ ggplot for Python. yhat. [2014-10-12]. (原始内容存档于2016-02-10). 
  18. ^ Interactive, online ggplot2 graphs. plotly. [2014-10-12]. (原始内容存档于2019-04-14). 
  19. ^ ggplot for Matlab. gramm. [2015-12-11]. (原始内容存档于2020-11-11). 

延伸阅读 编辑

外部链接 编辑