Module # 8 Correlation Analysis and ggplot2
library(ggplot2)
# use built-in dataset
data(mtcars)
# scatter plot with regression line
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point(color = "steelblue", size = 3) +
stat_smooth(method = "lm", se = FALSE, color = "black") +
labs(
title = "Relationship Between Horsepower and Fuel Efficiency",
x = "Horsepower",
y = "Miles Per Gallon"
) +
theme_minimal()
I used the built-in mtcars dataset in R to explore the relationship between horsepower and miles per gallon using a scatter plot with a regression line. The visualization shows a clear negative relationship, meaning cars with higher horsepower tend to have lower fuel efficiency. Using a simple layout with clear labels and minimal colors follows Few’s design recommendations by making the relationship between variables easy to interpret.
Comments
Post a Comment