I have a dataframe which contains a spatial variable with simulated and observed values.
df <- data.frame(sim = sample((20:30),10),
obs = sample(25:40,10),
long = rnorm(10,10,8),
lat = rnorm(10,30,15))
I have plotted a spatial bubble plot using the following code.
ggplot() +
geom_polygon(data = shp, aes(x = long, y = lat, group = group),
col = "black", lwd = 0.8, fill = "slategray1",
alpha = 0.5) +
coord_cartesian() +
geom_point(data = df, aes(x = long, y = lat, group = sim, size = sim), col = "red", alpha = 0.5) +
geom_point(data = df, aes(x = long, y = lat, group = obs, size = obs), col = "blue", alpha = 0.5) +
scale_size_continuous(range = c(10,20)) +
coord_map(xlim = c(-1, 22), ylim = c(10, 45))
The output of the above code is in the image. What I want to show in the plot is the difference between the simulated and observed data which is done perfectly. Now, I want to show two different legend for the two variable sim
and obs
which will be red and blue color legend respectively. Also I want to show the magnitude of the variable in the legend but not as the varying size of bubbles, but in some different way. Something like given here. Can someone help me in achieving this?