I have a data frame and I wonder how to plot a line using "max" (in red) with a filled area (in blue), and then add a second line using "min" (in green). Thanks a lot. The x-axis is "x".
df <- data.frame(
x = c("Jan","Feb","Mar","April","May","June","July"),
max = c(100,150,200,300,80,130,50),
min = c(30,20,40,25,15,10,8))
I have tried the following code:
df$x = 1:7
ggplot(df, aes(x)) +
geom_line(aes(y = max), color="red") +
geom_area() +
geom_line(aes(y = min), color = "blue")
But an error occurs: Error in eval(expr, envir, enclos) : object 'y' not found