



















Crafting Data Visualizations: Why R and ggplot2?
What makes ggplot2
different — and why should you choose it over tools like Excel or Tableau? This lesson dives into what sets R
and ggplot2
apart when it comes to customization, reproducibility, and the power of code.
Let's get a clear sense of when and why to reach for ggplot2
— and how it fits into the broader data visualization landscape.
🌍 A World of Visualization Tools
Data visualizations are everywhere—on web pages, in reports, and at the heart of dashboards.
What used to be a time-consuming, manual process is now much faster, thanks to powerful tools that turn raw data into clear, engaging graphics. But with so many options out there, choosing the right tool can be tough 😔.
There are 5 main categories of visualization tools. Some are quick-and-easy chart makers, while others are flexible, code-driven libraries.
The right choice depends on factors like data complexity, custom design, and the need for reproducibility. Explore the categories below to find the best fit for your needs!
👩💻 Why Coding?
1️⃣ Reproducibility
When you generate visualizations through code, every step is explicit and repeatable. You can easily reuse or tweak your code to update visuals with new data, saving time and ensuring consistency.
Unlike point-and-click tools, a code-first approach offers unparalleled transparency, reproducibility, and efficiency.
2️⃣ Customization
Coding also opens the door to full customization— fine-tune the layout, modify colors and shapes, add dynamic labeling logic, or craft uncommon charts.
Scroll through those charts we've built in the past. Not many visualization tools allows such a level of customization!













A few graphs made by Cédric using ggplot2
. For more stunning examples, check Yan's R Graph Gallery!
3️⃣ Automatisation
Programing also allows you to simplify your workflow by creating custom functions that then can be used to:
- automate the process of creating plots for a range of subsets, variable combinations, or even data sets;
- apply your personal theme or corporate style guide to ensure consistent and efficient styling (colors, fonts, spacing, etc.) across all your plot;
- easily create a series of charts that reveal your data step-by-step, a powerful way when telling a story with data.
Doesn't that sound great? 😎
📦 Why ggplot2?
ggplot2
📦 is the most downloaded R package might be striking, too!ggplot2
is one of the most powerful tools in the world of data visualizations: By adhering to the Grammar of Graphics, it provides an elegant framework for crafting visualizations using consistent, composable building blocks.
This approach allows you to combine different components to create everything— from simple bar charts to complex, multi-faceted plots with just a few lines of code.
The idea behind ggplot2 comes from a book called “The Grammar of Graphics” by Leland Wilkinson. It inspired a whole new way to think about data visualization—treating charts as layered, structured expressions of data.
ggplot2 was the first major tool to bring this theory to life, and its influence can now be seen in tools like Vega, Altair, Plotnine, and even Power BI! Many modern JavaScript libraries like D3.js and Observable Plot also embrace the same philosophy, letting users declaratively compose charts using shared principles.
The ggplot2
📦 is widely used by researchers, journalists, and analysts alike. Its rich ecosystem of extensions and a vibrant community make it a go-to solution for high-quality, publication-ready graphics.
🚀 Let's do this!
Hopefully, you're now convinced that learning to make charts with R and ggplot2
is a smart move for creating insightful graphs.
It's time to roll up our sleeves, dive into the principles of ggplot2
, and write our first lines of code.
But before we jump into the next lesson, let's do a quick check to reinforce what you've learned— and maybe pick up a fun fact or two along the way!
Which of the following is not a programming-based visualization tool?
What is one major benefit of creating visualizations through code?
Who wrote the influential book "The Grammar of Graphics"?
Which of the following is correct about ggplot2?
When was ggplot2 first release?