So I have three lines that I'm charting. The upper and lower lines are the confidence interval, so I'd like to use geom_ribbon() to fill in the area between the lines with color. But I haven't been able to figure it out. I think the below code makes it clear what I'm trying to accomplish, but this doesn't work and provides the following error: "Discrete value supplied to continuous scale."
library(ggplot2)
library(gganimate)
rise3 %>%
ggplot(aes(x=as.numeric(Year),
y=CM_increase,
group=Scenario))+
geom_line(color="#134e13",
size=1.25) +
geom_ribbon(aes(x=as.numeric(Year),
ymax=Scenario == "1.5 - MED",
ymin=Scenario == "0.5 - MED")) +
transition_reveal(as.numeric(Year)) +
theme_hc()
Here is what the dataset looks like
Site ID Latitude Longitude Scenario RSL_rate Year CM_increase
1 SEWELLS POINT 299 36.95 -76.33 0.5 - MED 2.47 2000 0
2 SEWELLS POINT 299 36.95 -76.33 1.0 - MED 2.47 2000 0
3 SEWELLS POINT 299 36.95 -76.33 1.5 - MED 2.47 2000 0
4 SEWELLS POINT 299 36.95 -76.33 0.5 - MED 2.47 2010 7
And a chart of the three lines:
I was also asked for the following output:
dput(head(rise3, 20))
structure(list(Site = c("SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT",
"SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT",
"SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT",
"SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT",
"SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT", "SEWELLS POINT",
"SEWELLS POINT"), `PSMSL ID` = c(299L, 299L, 299L, 299L, 299L,
299L, 299L, 299L, 299L, 299L, 299L, 299L, 299L, 299L, 299L, 299L,
299L, 299L, 299L, 299L), Latitude = c(36.95, 36.95, 36.95, 36.95,
36.95, 36.95, 36.95, 36.95, 36.95, 36.95, 36.95, 36.95, 36.95,
36.95, 36.95, 36.95, 36.95, 36.95, 36.95, 36.95), Longitude = c(-76.33,
-76.33, -76.33, -76.33, -76.33, -76.33, -76.33, -76.33, -76.33,
-76.33, -76.33, -76.33, -76.33, -76.33, -76.33, -76.33, -76.33,
-76.33, -76.33, -76.33), Scenario = c("0.5 - MED", "1.0 - MED",
"1.5 - MED", "0.5 - MED", "1.0 - MED", "1.5 - MED", "0.5 - MED",
"1.0 - MED", "1.5 - MED", "0.5 - MED", "1.0 - MED", "1.5 - MED",
"0.5 - MED", "1.0 - MED", "1.5 - MED", "0.5 - MED", "1.0 - MED",
"1.5 - MED", "0.5 - MED", "1.0 - MED"), `Background RSL rate (mm/yr)` = c(2.47,
2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47,
2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47, 2.47), Year = c("2000",
"2000", "2000", "2010", "2010", "2010", "2020", "2020", "2020",
"2030", "2030", "2030", "2040", "2040", "2040", "2050", "2050",
"2050", "2060", "2060"), CM_increase = c(0L, 0L, 0L, 7L, 9L,
11L, 15L, 19L, 24L, 22L, 30L, 38L, 30L, 42L, 54L, 37L, 55L, 73L,
45L, 70L)), row.names = c(NA, 20L), class = "data.frame")
Any guidance would be appreciated.