How to add a bubble size legend to a geoscatter plot

조회 수: 13 (최근 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 CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by