1/34
Vocabulary flashcards covering the components, aesthetics, geoms, scales, coordinates, faceting, and theming of the ggplot2 package in R.
ggplot2
An R package based on the layered grammar of graphics where plots are constructed by iteratively adding layers composed of data and aesthetic mappings.
Three Key Components of a ggplot
The foundational elements present in every plot: tidy data (observations in rows, variables in columns), aesthetic mappings via aes(), and at least one layer typically generated by a geom_*() function.
Aesthetic Mappings (aes())
Descriptions that specify how variables in the dataset correspond to visual properties of a graphic, such as position, color, shape, and size.
Layer
A visual building block in ggplot2 composed of a collection of geometric elements and statistical transformations.
Scales (scale_*())
Functions that map values from data space into aesthetic space, governing the presentation of aesthetic mappings including axis ranges, labels, color palettes, and legend formats.
Coord (coord_*())
Functions that define how data coordinates and plotted geometries are mapped onto the graphic's two-dimensional plane.
Faceting
A technique that partitions data into subsets based on categorical variables and renders each subset in a distinct subplot within a matrix or grid of small multiples.
Theme (theme())
The master control function for non-data visual elements of a graphic, adjusting components such as backgrounds, grid lines, text labels, fonts, and legend positioning.
Rendering
The visual output generation stage analogous to cooking a meal from a written recipe, where the stored plot object is drawn or printed to the screen.
alpha
An aesthetic attribute controlling point transparency, where 0 represents complete invisibility and 1 is the default fully opaque setting.
Fixed Aesthetic Attribute
A visual parameter passed directly inside a geom_*() function outside of aes(), applying a constant appearance setting rather than scaling to a variable.
scale_color_brewer()
A scale function linked to the ColorBrewer cartography system designed to apply specialized, professional palettes to point and line colors.
scale_fill_brewer()
A scale function that applies ColorBrewer color palettes to the interior fill of geoms such as bars, boxplots, histograms, and shaded areas.
Qualitative Palettes (ColorBrewer)
Palettes such as Set1, Dark2, and Paired designed for nominal categorical variables that lack intrinsic order.
Sequential Palettes (ColorBrewer)
Palettes such as Blues, YlGnBu, and Reds designed for ordered categories or continuous ranges mapped to factors.
Diverging Palettes (ColorBrewer)
Palettes such as RdBu, Spectral, and PiYG designed to emphasize deviations above and below a central zero or mean value.
facet_wrap()
A faceting function that arranges a 1-dimensional sequence of subplots across a 2-dimensional grid from left to right and top to bottom.
facet_grid()
A faceting function that arranges subplots along explicit row and column categorical variables to examine the interaction between two factors.
scales = "free"
A faceting parameter that releases the constraint of identical axis limits, allowing each subplot panel to find its own optimal axis boundaries.
geom_smooth()
A geom layer function that fits a statistical trendline smoother to the data and plots the smooth curve alongside its standard error.
LOESS (Locally Estimated Scatterplot Smoothing)
A flexible, non-parametric smoothing method used by default in geom_smooth() for datasets with n<1000 to produce a curve following local variations.
span (LOESS)
A tuning parameter between 0 and 1 specifying the proportion of total data points utilized to compute each local fit.
GAM (Generalized Additive Model)
The default smoothing method used by geom_smooth() when fitting trends for large datasets with n>1000.
geom_jitter()
A geom layer shortcut that adds random coordinate noise (defaulting to 40% of data resolution) to disperse overlapping points and reveal dense clusters.
coord_cartesian()
A coordinate function that visually zooms in on a specified coordinate region after statistical computations and transformations have completed, avoiding row deletion.
coord_flip()
A coordinate function that interchanges the horizontal and vertical axes, often used to turn vertical bar charts into horizontal ones.
coord_fixed()
A coordinate function that enforces a fixed aspect ratio where k units on the x-axis equal 1 unit of physical length on the y-axis.
coord_polar()
A coordinate function that maps Cartesian coordinates onto a circular grid, transforming geometric objects like bar charts into pie charts.
patchwork
An R package that combines separate ggplot objects into unified multi-panel layouts using arithmetic operators such as + for rows and / for columns.
ggsave()
A dedicated export function used to save plot objects to disk with user-defined file dimensions, defaulting to the last rendered plot when omitted.
element_text()
A theme helper function used to format typography, controlling parameters such as font size, face, color, and alignment for titles and axis labels.
hjust and vjust
Text-alignment parameters in theme elements where 0 is left or bottom aligned, 0.5 is centered or middle aligned, and 1 is right or top aligned.
element_line()
A theme helper function that specifies visual properties (such as color, size, and line type) for line components like axes and grid lines.
element_rect()
A theme helper function that specifies colors, borders, and fills for rectangular non-data areas like plot and panel backgrounds.
element_blank()
A theme function used to completely suppress drawing and remove targeted non-data components from a graphic.