How can I edit colors and set limits for a ggplot contour map?

Viewed 618

I use ggplot's geom_contour_filled to plot this map. I want to change the legend ranges from -2 to 11, like I wrote in the argument breaks = c(-Inf,-2., -1.5, -1., -0.5, 0, 0.5, 1, 1.5, 2, 3, 4, 5, 7, 9, 11,Inf), but the plot only shows the color that appears in the graph. Also, ggplot automatically set the colors for the variables, but is it possible to edit the color of the contour?

Here is my code:

ggplot(map, aes(y=Latitude, x=Longitude, z=variable)) +
  ggtitle(title)+
  geom_contour_filled(breaks = c(-Inf,-2., -1.5, -1., -0.5, 0, 0.5, 1, 1.5, 2, 3, 4, 5, 7, 9, 11,Inf))+
  geom_map(data=world, map=world,
           aes(long, lat, map_id=id),
           size=0.1, fill=NA, color = "grey") + #America and Greenland
  geom_map(data=canada, map=canada,
           aes(long, lat, map_id=id),
           size=0.2, fill=NA, color = "black")+ #Canada
  xlim(-146,-44)+
  ylim(35,90)+
  theme(plot.title = element_text(hjust = 0.5))

My current map: My current map

My desired map: My goal map looks like

0 Answers
Related