Write R code using ggplot2 to create a line plot for the data frame temperature with day on the x-axis and temp on the y-axis. Make the line green and use a minimal theme.
Once you know the basics, ggplot2
allows you to customize almost every aspect of a plot, from colors and shapes to labels and themes.
library(ggplot2)
df <- data.frame(
x = 1:5,
y = c(2, 4, 6, 8, 10)
)
ggplot(df, aes(x = x, y = y)) +
geom_line(color = "blue") +
ggtitle("Line Plot of X vs Y") +
xlab("X Axis") +
ylab("Y Axis")
ggplot(df, aes(x = x, y = y)) +
geom_line(color = "red") +
theme_minimal()
Themes help give your plots a polished look, and you can customize colors, fonts, grid lines, and more.