
In Excel each chart type is a different menu. In R’s ggplot2 every chart is built the same way: data + aesthetics (which column goes where) + a geometry (bars, lines, points).
In this article
Setup
install.packages(c("ggplot2", "dplyr"))
library(ggplot2); library(dplyr)
sales <- data.frame(
month = factor(month.abb[1:6], levels = month.abb[1:6]),
north = c(120, 135, 128, 150, 162, 170),
south = c(90, 95, 110, 105, 118, 125))
Bar chart
ggplot(sales, aes(x = month, y = north)) +
geom_col(fill = "#e47f53") +
labs(title = "North sales by month", x = NULL, y = "₹ thousands")
Line chart with two series
ggplot prefers “long” data: one row per month per region. tidyr::pivot_longer is R’s unpivot.
library(tidyr)
long <- pivot_longer(sales, c(north, south), names_to = "region", values_to = "amount")
ggplot(long, aes(month, amount, colour = region, group = region)) +
geom_line(linewidth = 1.2) + geom_point(size = 2) +
theme_minimal()
Save it
ggsave("sales.png", width = 8, height = 4.5, dpi = 150)
💡 Add
facet_wrap(~ region) to draw one small chart per region — something that takes many steps in Excel.Start with R for Excel users if R is new to you.