Ggplot2 Explained
ggplot2 is an open-source data visualization package for the statistical programming language R. Created by Hadley Wickham in 2005, ggplot2 is an implementation of Leland Wilkinson's Grammar of Graphics—a general scheme for data visualization which breaks up graphs into semantic components such as scales and layers. ggplot2 can serve as a replacement for the base graphics in R and contains a number of defaults for web and print display of common scales. Since 2005, ggplot2 has grown in use to become one of the most popular R packages.[1] [2] [3]
Updates
On 2 March 2012, ggplot2 version 0.9.0 was released with numerous changes to internal organization, scale construction and layers.[4]
On 25 February 2014, Hadley Wickham formally announced that "ggplot2 is shifting to maintenance mode. This means that we are no longer adding new features, but we will continue to fix major bugs, and consider new features submitted as pull requests. In recognition [of] this significant milestone, the next version of ggplot2 will be 1.0.0".[5]
On 21 December 2015, ggplot 2.0.0 was released. In the announcement, it was stated that "ggplot2 now has an official extension mechanism. This means that others can now easily create their [own] stats, geoms and positions, and provide them in other packages."[6]
Comparison with base graphics and other packages
In contrast to base R graphics, ggplot2 allows the user to add, remove or alter components in a plot at a high level of abstraction.[7] This abstraction comes at a cost, with ggplot2 being slower than lattice graphics.[8]
Creating a different plot for various subsets of the data requires for loops and manual management in base R graphics, whereas ggplot2 simplifies that process with a collection of "facet" functions to choose from.[9]
One potential limitation of base R graphics is the "pen-and-paper model" utilized to populate the plotting device.[10] Graphical output from the interpreter is added directly to the plotting device or window, rather than separately for each distinct element of a plot.[11] In this respect it is similar to the lattice package, though Wickham argues ggplot2 inherits a more formal model of graphics from Wilkinson.[12] As such, it allows for a high degree of modularity; the same underlying data can be transformed by many different scales or layers.[13] [14]
Plots may be created via the convenience function qplot
where arguments and defaults are meant to be similar to base R's plot
function.[15] [16] More complex plotting capacity is available via ggplot
which exposes the user to more explicit elements of the grammar.[17]
Related projects
- ggpy, ggplot for Python,[18] but has not been updated since 2016-11-20
- plotnine[19] started as an effort to improve the scalability of ggplot for Python and is largely compatible with ggplot2 syntax.
- Plotly - Interactive, online ggplot2 graphs[20]
- gramm, a plotting class for MATLAB inspired by ggplot2[21]
- gadfly, a system for plotting and visualization written in Julia, based largely on ggplot2[22]
- Chart::GGPlot - ggplot2 port in Perl[23]
- The Lets-Plot for Python library includes a native backend and a Python API, which was mostly based on the ggplot2 package well-known to data scientists who use R.[24]
- Lets-Plot Kotlin API is an open-source plotting library for statistical data implemented using the Kotlin programming language, and is built on the principles of layered graphics first described in the Leland Wilkinson's work The Grammar of Graphics.[25]
- ggplotnim, plotting library using the Nim programming language inspired by ggplot2.[26]
Further reading
Notes and References
- Wickham. Hadley. ggplot2: Elegant Graphics for Data Analysis. Journal of Statistical Software. July 2010. 35. 1.
- Wilkinson. Leland. Leland Wilkinson. ggplot2: Elegant Graphics for Data Analysis by WICKHAM, H. Biometrics. June 2011. 67. 2. 678–679. 10.1111/j.1541-0420.2011.01616.x.
- Web site: CRAN - Package ggplot2. 12 October 2023 .
- Web site: ggplot2 Development Team. Changes and Additions to ggplot2-0.9.0. 31 October 2017. 26 January 2015. https://web.archive.org/web/20150126062502/https://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf. dead.
- Web site: Wickham. Hadley. ggplot2 development. ggplot2 Google Group. 26 February 2014.
- Web site: ggplot 2.0.0 . 2021-06-21 . 21 December 2015 . https://web.archive.org/web/20210207054047/https://blog.rstudio.com/2015/12/21/ggplot2-2-0-0/ . 2021-02-07 . live.
- Web site: Smith. David. Create beautiful statistical graphics with ggplot2. Revolutions. Revolution Analytics. 11 July 2011.
- Web site: ggplot2 Version of Figures in "Lattice: Multivariate Data Visualization with R" (Final Part). 25 August 2009 .
- Web site: Yau . Nathan . Comparing ggplot2 and R Base Graphics . FlowingData . 17 April 2022 . en . 22 March 2016.
- Book: Wickham, Hadley. ggplot2: Elegant Graphics for Data Analysis . 2009 . Springer . 978-0-387-98140-6. 5.
- Murrell . Paul . R Graphics. Wiley Interdisciplinary Reviews: Computational Statistics. August 2009. 1. 2. 216–220. 10.1002/wics.22. 37743308 .
- Book: Sarkar, Deepayan. Lattice: multivariate data visualization with R. 2008. Springer. 978-0-387-75968-5. xi.
- Book: Teetor, Paul. R Cookbook. 2011. O'Reilly. 978-0-596-80915-7. 223.
- Wickham. Hadley. March 2010. A Layered Grammar of Graphics. Journal of Computational and Graphical Statistics. 19. 1. 3–28. 10.1198/jcgs.2009.07098. 58971746.
- Book: R: A language and environment for statistical computing. 2011. R Foundation for Statistical Computing. Vienna, Austria. 978-3-900051-07-5. R Development Core Team.
- Ginestet. Cedric. ggplot2: Elegant Graphics for Data Analysis . Journal of the Royal Statistical Society, Series A . January 2011 . 174 . 1 . 245–246 . 10.1111/j.1467-985X.2010.00676_9.x.
- Book: Muenchen. Robert A.. Hilbe. Joseph M . R for Stata Users . Springer . 978-1-4419-1317-3 . 10.1007/978-1-4419-1318-0_16 . Graphics with ggplot2. Statistics and Computing. 2010. 385–452.
- Web site: yhat/ggpy: ggplot port for python . 2024-02-01 . . yhat.
- Web site: plotnine . 2 August 2023.
- Web site: Plotly graphing library for ggplot2 in ggplot2 . 2024-02-01 . Plotly Graphing Libraries . Plotly.
- Web site: ggplot for Matlab . 11 December 2015 . . Pierre Morel (@piermorel).
- Web site: Gadfly.jl . 11 September 2018 . Gadfly.jl.
- Web site: Stephan Loyd/Chart-GGPlot-0.0001 . 30 March 2019 . MetaCPAN.
- Web site: JetBrains/lets-plot . 3 April 2021 . . JetBrains.
- Web site: JetBrains/lets-plot-kotlin . 4 April 2021 . . JetBrains.
- Web site: ggplotnim . 1 August 2023 . . Vindaar.