I am working on a homework assignment in R Studio and keep getting the Error: Discrete value supplied to continuous scale error. When doing this part: ggplot()+plot1+plot2+plot3 + coord_equal() + scale_fill_gradient( low="#473B31", high="#FFFFFF")
I am not sure how to fix this Ive looked for seimilar solutions but cant find any that help me. Here is the full line of commands we are supposed to enter I highlighted where the issue was
# Create choropleth
plot1<- c(geom_polygon(data=LSOA_FF, aes(long, lat, group = group, fill = imd_rank)))
# Create road plot
plot2<-c(geom_path(data=roads_FF,aes(x=long, y=lat, group=group),size=0.1))
# Combine the plots
ggplot()+plot1+plot2+coord_equal()
We can add a further layer for the locations of the schools, and also adjust the color ramp.
# Create school plot
plot3 <- c(geom_point(data=schools, aes(Easting, Northing,colour='school')))
# Create combined plot
**ggplot()+plot1+plot2+plot3 + coord_equal() + scale_fill_gradient( low="#473B31", high="#FFFFFF")**
**#issue here**
It is also possible to control the other elements of the plot using "theme_bw()" which removes many of the visible elements.
#Create a clean plot
ggplot()+plot1+plot2+plot3 +coord_equal() + scale_fill_gradient( low="#473B31", high="#FFFFFF") + theme_bw()
However, the plot is still a little cluttered and we can turn off many of the elements using "theme()"
ggplot()+plot1+plot2+plot3 +coord_equal() + scale_fill_gradient( low="#473B31", high="#FFFFFF") + theme_bw() +
theme(axis.line = element_blank(),
axis.text = element_blank(),
axis.title=element_blank(),
axis.ticks = element_blank(),
legend.key = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank()) + labs(fill = "IMD Rank",colour="")