When would you use base R graphics functions versus ggplot2 for data visualization?

Quick Overview

Asks when to use base R graphics and when to use ggplot2 for data visualization in R. Tests understanding of the two plotting models, the data shape each one expects, and how to pick between quick exploratory plots and layered, shareable graphics.

When would you use base R graphics functions versus ggplot2 for data visualization?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

When would you use base R graphics functions versus `ggplot2` for data visualization? ```hint Try a harder plot Think about what each system needs from you to color points by a group, add a legend, and split the plot into one panel per category. ``` ### What a Strong Answer Covers - The drawing model of each system and what it means for adding elements to a plot - Situations where base graphics is the faster or simpler choice - Situations where `ggplot2` grouping, faceting, legends and themes save work - The data shape each system expects and the reshaping that may be needed ### Follow-up Questions - How would you build a colored, faceted scatter plot in base R, and what makes it harder than in `ggplot2`? - Why does calling `abline()` after printing a `ggplot2` plot not work as expected, and what do you use instead? - How would you keep a consistent look across 20 plots in one report? - When would you move to an interactive plotting library instead of either of these?

Overview: Asks when to use base R graphics and when to use ggplot2 for data visualization in R. Tests understanding of the two plotting models, the data shape each one expects, and how to pick between quick exploratory plots and layered, shareable graphics.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

When would you use base R graphics functions versus ggplot2 for data visualization?

What a Strong Answer Covers Guidance

  • The drawing model of each system and what it means for adding elements to a plot
  • Situations where base graphics is the faster or simpler choice
  • Situations where ggplot2 grouping, faceting, legends and themes save work
  • The data shape each system expects and the reshaping that may be needed

Follow-up Questions Guidance

  • How would you build a colored, faceted scatter plot in base R, and what makes it harder than in ggplot2 ?
  • Why does calling abline() after printing a ggplot2 plot not work as expected, and what do you use instead?
  • How would you keep a consistent look across 20 plots in one report?
  • When would you move to an interactive plotting library instead of either of these?