ggplot2 Quick Reference – Basic Plot Types in R
Plot Type ggplot2 Code Example
Bar Chart (Count by Category) ggplot(data, aes(x = category)) +
geom_bar(fill = "skyblue")
Bar Chart (With Custom Y Values) ggplot(data, aes(x = category, y = value)) +
geom_col(fill = "coral")
Box Plot ggplot(data, aes(x = group, y = value)) +
geom_boxplot(fill = "lightgreen")
Scatter Plot ggplot(data, aes(x = var1, y = var2)) +
geom_point(color = "purple")
Line Graph ggplot(data, aes(x = time, y = value)) +
geom_line(color = "blue")
Histogram ggplot(data, aes(x = numeric_var)) +
geom_histogram(binwidth = 5, fill =
"orange")
Add Title and Axis Labels + labs(title = "Plot Title", x = "X Label", y =
"Y Label")
Clean Theme + theme_minimal()