How to add a bubble size legend to a geoscatter plot

12 ビュー (過去 30 日間)
Elliot Jenkins
Elliot Jenkins 2023 年 1 月 16 日
回答済み: Trevor 2023 年 1 月 19 日
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);

採用された回答

Trevor
Trevor 2023 年 1 月 19 日
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 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by