Data visualization is where statistics meets communication. After writing a handbook on ggplot2 and teaching visualization to many students, I’ve developed a set of principles that consistently produce better charts.

The Grammar of Graphics Actually Matters

When people first learn ggplot2, they often treat it like a function library — calling geom_bar() or geom_line() to get a chart type. The real power comes from understanding the grammar underneath: data, aesthetics, geometries, scales, coordinates, and themes as composable layers.

library(ggplot2)
library(scales)

ggplot(data, aes(x = year, y = value, color = group)) +
  geom_line(linewidth = 1.2) +
  geom_point(size = 2.5) +
  scale_color_brewer(palette = "Set2") +
  scale_y_continuous(labels = label_comma()) +
  labs(
    title = "Clear, Specific Title",
    subtitle = "Context that helps the reader",
    caption = "Source: Your data source here"
  ) +
  theme_minimal(base_size = 13) +
  theme(
    plot.title = element_text(face = "bold", size = 15),
    legend.position = "bottom"
  )

The Single Most Important Improvement

Add proper axis labels and a descriptive title. It sounds obvious, but the majority of charts I see in student projects and research papers have cryptic axis labels like var1 or count. Treat your chart like a document — it should be interpretable without reading the surrounding text.

Going Interactive with Plotly

For dashboards and exploratory analysis, converting ggplot2 charts to interactive Plotly objects is one line:

library(plotly)
p <- ggplot(...) + ...
ggplotly(p)

Happy plotting!