How to add a bubble size legend to a geoscatter plot
11 views (last 30 days)
Show older comments
I have made a geoscatter plot with parameter 1 being indicated with the colour of the bubble and parameter 2 being indicated by the size of the bubble. I have inserted a colorbar indicating the values for paramater 1. But is there a way I could I add a legend for the size of the bubble on the figure as well or is there a different way to work around the problem?
I just want a way to show the legend for the size of the bubbles as well as the colorbar
s=geoscatter(lat,lon,total,sgi,"filled");
geobasemap streets-dark
geolimits([49.5 60], [-5 -2]);
c.Ticks = [-2 -1.5 -1 0];
clim ([-3 0])
c = colorbar('eastoutside');
c.Label.String = "SGI";
title('Spatial plot of SGI and total drought duration for 1970s')
colormap parula(100);
0 Comments
Accepted Answer
Trevor
on 19 Jan 2023
Unfortunately, there isn't a proper way to do this currently.
The main workaround would be to use "geobubble" and split your color data into different groups. "geobubble" shows a legend of the size of the bubble automatically, but it also allows a set of categorical color data and shows a legend of that color data.
This doesn't give you a colorbar, but it does provide a legend on which you can show the ranges of the colors, which may be enough detail depending on your use case. You can name the categories after the sizes of the ranges, and they will appear on the legend.
You can find the documentation for "geobubble" here:
I have also submitted this as an enhancement request so that it can be considered in the future.
0 Comments
More Answers (0)
See Also
Categories
Find more on Geographic Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!