gitmyhub

ggplot2

R ★ 7.0k updated 2mo ago

An implementation of the Grammar of Graphics in R

An R package for making charts and graphs by describing what you want in code, map your data to axes and colors, then add layers like points, bars, or lines to build up a visualization.

RCRANsetup: easycomplexity 2/5

ggplot2 is an R package for making charts and graphs. It is one of the most widely used tools for data visualization in the R programming language, and it is installed by hundreds of thousands of people. The core idea is that you describe what you want to see by specifying your data and how different variables should map to visual properties like position, color, or size, and the library figures out how to draw it.

The approach is built around layering: you start with a base call that sets the dataset and the axes, then you add layers for the actual marks (points, lines, bars, histograms), then optional layers for colors or scales, and then optional facets if you want to split the chart into small multiples. A short example in the README shows three lines of R code producing a colored scatter plot of car engine size versus fuel efficiency.

Installation is a single command in R, either as part of the broader tidyverse collection of packages or on its own from CRAN, the standard R package repository.

The project is mature and stable: the README notes it is 18 years old and changes slowly by design, with most new development happening in the ecosystem of extension packages rather than in ggplot2 itself. A gallery of community extensions is maintained separately.

For learning, the README points to several resources: chapters in the free online book R for Data Science, an O'Reilly video course, a YouTube webinar, the R Graphics Cookbook for quick recipes, and a dedicated ggplot2 book for deeper understanding of the theory. Help is available through the Posit Community forums and Stack Overflow.

Where it fits