Chapter 36: R Plotting

R Plotting — probably the single most enjoyable (and addictive) part of learning R.

Many people fall in love with R exactly because of how beautiful and flexible the plots can be. You can go from a quick 3-line exploratory chart to publication-ready, journal-quality figures in the same session.

We’ll cover this like a real classroom lesson:

  • the two main systems (base vs ggplot2)
  • when to use which
  • step-by-step examples you can copy-paste right now
  • common customizations
  • saving high-quality files
  • modern 2026 workflow

1. Two Plotting Worlds in R (2026 Perspective)

System Package First impression Best for Learning investment Final look (default) Community dominance 2026
Base R graphics Very fast Quick exploration, diagnostic plots, teaching Low Classic / dated ~20–30 %
ggplot2 ggplot2 Takes 5–10 min Almost everything else: reports, papers, blogs, dashboards Medium → high payoff Modern, clean, professional ~70–80 %

Short rule of thumb most people follow in 2026:

  • plot(), hist(), boxplot() → quick look in console
  • everything you want to show to others → ggplot2

2. Base R Plotting – Fast & Always Available

No installation needed — these are built-in.

Quick scatter plot

R

Histogram + density

R

Boxplot by group

R

3. ggplot2 Plotting – The Modern Professional Standard

Install once (if not already):

R

Basic philosophy (very important to remember)

A ggplot is built in layers:

  1. data + mapping (aes()) → what goes where
  2. geoms → how to draw (points, lines, bars…)
  3. scales → colors, axes, legends
  4. facets → small multiples
  5. themes → overall look
  6. labs() → titles, labels

Classic scatter plot (compare to base)

R

Bar plot with Hyderabad flavor

R

Faceted plot (small multiples – very powerful)

R

4. Saving Plots (Very Important for Reports)

Base R

R

ggplot2 – preferred ways

R

5. Quick 2026 Workflow Recommendation

  1. Explore fast → base R (plot(), hist(), boxplot())
  2. Polish for sharing → ggplot2
  3. Combine multiple plots → use patchwork package
R
  1. Make interactive (bonus) → plotly::ggplotly(p) or ggiraph

Your Turn – Mini Practice

Copy and run this block — then try changing colors, themes, adding facets:

R

Want to go deeper?

  • Specific ggplot2 topics (themes, scales, annotations, facets)?
  • Saving publication-ready figures (CMYK, high-res)?
  • Combining base + ggplot in one report?
  • Or next topic (dplyr data wrangling before plotting)?

Just say — next lesson is ready! 📊✨🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *