ggplot2 Chapters

You already know the ggplot2 basics - now it is time to take full control of your plots. This section covers axis customization, color palettes, theme design, export, advanced plot types, facetting, and useful extension packages.

Prerequisites: Before diving in, you should be comfortable with the content from First ggplot and Factors.

How to navigate ..

.. through chapters

You can navigate chapters by clicking on the table of chapters on the left. Alternatively, you can always go to the next chapter by clicking on its name at the end (i.e. scroll all the way down)

.. through content within chapters

Within a chapter, you can navigate through the content by clicking on the table of contents on the right.

Chapter overview

PlantGrowth chapters (01-04): Starting from a simple scatter plot, we progressively refine every aspect - axes, colors, themes, and export - using the built-in PlantGrowth dataset.

Chapter Topic
1. Axes Customize axis titles, limits, breaks, labels, and expand
2. Colors Static aesthetics, aes() mapping, palettes, colorblind-friendly options
3. Themes Complete themes, theme() elements, Google Fonts, ggtext
4. Export and Canvas The canvas problem, ggsave, camcorder

gapminder chapters (05-06): We apply everything learned so far to build publication-ready plots from scratch with a richer dataset.

Chapter Topic
5. Advanced Plots Step-by-step custom theme, grouped bar charts, dumbbell plots, data labels
6. Facets facet_wrap(), free scales, ggh4x for individual axis formatting

Extension packages (07-09): Useful ggplot2 extensions for common visualization challenges.

Chapter Topic
7. ggrepel Non-overlapping text labels for scatter plots
8. ggforce Zooming, annotations, and group marking
9. patchwork Combining multiple plots into one figure