Chapter 35: R Graphics

R Graphics — one of the most exciting (and sometimes frustrating) parts of R.

R has always been famous for its graphics capabilities — people choose R over other tools precisely because it can produce publication-quality plots, custom infographics, and interactive dashboards. In 2026, the landscape is very clear: there are two main systems, and almost everyone ends up using both at different moments.

I’ll explain it like we’re sitting together in RStudio — slowly, with lots of copy-paste examples, comparisons, pros/cons, and the modern workflow most people use right now.

1. The Two Worlds of R Graphics (2026 Reality)

System Package(s) When people use it (2026) Learning curve Speed (simple plots) Customization power Publication quality Interactive?
Base R Built-in (graphics, grDevices, lattice) Quick checks, residuals, very simple plots, legacy code Low Very fast Medium Good (but dated look) No
ggplot2 ggplot2 (tidyverse) Almost everything: reports, papers, dashboards, Shiny Medium Slower (but acceptable) Extremely high Excellent (modern, clean) No (but extensions yes)

Quick verdict 2026:

  • Use base R for fast exploratory plots (like plot(), hist(), boxplot())
  • Use ggplot2 for everything you want to share, publish, or polish (99% of final graphics)

2. Base R Graphics – Quick & Built-in

These functions live in base R — no install.packages() needed.

Classic examples (run these right now!)

R

→ Fast, but legend is manual, colors are default, looks a bit 1990s.

Histogram & boxplot

R

Line plot (time series style)

R

3. ggplot2 – The Modern Standard (Highly Recommended)

ggplot2 follows the Grammar of Graphics philosophy:

  • data → the data frame
  • aes() → aesthetics (what goes where: x, y, color, size…)
  • geom_ → geometric objects (points, lines, bars…)
  • + → add layers

Install once (if not already):

R

Basic scatter plot (compare to base)

R

→ Automatic legend, better defaults, easy to customize.

Add trend lines

R

Bar plot (Hyderabad style example)

R

4. Quick Comparison Table (2026 Perspective)

Feature Base R ggplot2 Winner (most cases)
Speed (simple plot) Very fast Slower (but usually < 1 sec) Base
Learning curve Low at first Medium (but pays off fast) Base (day 1)
Customization Possible but manual Layered, intuitive ggplot2
Aesthetics (default) Dated Modern, publication-ready ggplot2
Facets / small multiples Manual Built-in facet_wrap() / facet_grid() ggplot2
Themes Limited theme_minimal(), theme_bw(), custom themes ggplot2
Interactive extensions No plotly, ggiraph, ggforce ggplot2
Use in Shiny / dashboards Possible Natural fit ggplot2

5. Modern Workflow Recommendation (2026)

  • Day-to-day exploration → base R (plot(), hist(), boxplot()) — super quick
  • Anything you’ll share (reports, thesis, blogs, presentations) → ggplot2
  • Use R Markdown / Quarto to mix code + plots + text → export PDF/HTML/Word
  • Extensions you’ll love:
    • ggthemes — extra themes (economist, solarized, etc.)
    • patchwork — combine multiple ggplots easily
    • ggpubr — publication-ready stats on plots
    • plotly::ggplotly() — turn ggplot into interactive HTML plot

Your Mini Practice Right Now

R

Which one looks nicer to you? 😄

Ready for next?

  • Want to go deeper into ggplot2 layers (geoms, scales, themes)?
  • Practice saving plots (png, pdf, high-res)?
  • Or build a small dashboard-style example with multiple plots?

Just tell me — whiteboard is ready! ☕📈🚀

You may also like...

Leave a Reply

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