- Explicitly create a set geographic axes (using "geoaxes").
- Add a "bubblechart" which, unlike "geobubble", can be combined with other plots. If desired, a legend can be added with "bubblelegend" and the bubbles can be styled with the other "bubble-" functions like "bubblesize" and "bubblelim".
- Add extra plots with "geoplot".
How do I add polygons to a map created with "geobubble"?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 26 de Mayo de 2023
Respondida: MathWorks Support Team
el 1 de Jun. de 2023
I have some geographic data to display with a bubble plot, along with an SHP file containing polygonal regions which also want to be plotted (in this case "landareas.shp", which ships with MATLAB). I can load the data with this code:
bubbleLats = [52.20 51.75 52.95 26.07];
bubbleLons = [0.13 -1.26 -1.15 50.56];
bubbleSizes = [1 2 3 4];
regions = readgeotable("landareas.shp");
Now I want to create a geographic plot containing both the bubbles and regions. The result should look look something like this:
I have tried the following code:
figure
geobubble(bubbleLats, bubbleLons, bubbleSizes);
geolimits([50 60], [-15 5]);
geobasemap streets
mapshow(regions)
The bubbles are displayed, but "mapshow" fails with the following error:
Error using mapshow
Expected Parent to be one of these types:
matlab.graphics.axis.Axes
Instead its type was matlab.graphics.chart.GeographicBubbleChart.
Why is this not working? And how do I simultaneously plot the polygons and the bubbles on a map?
Respuesta aceptada
MathWorks Support Team
el 26 de Mayo de 2023
It is not possible to combine "geobubble" with other plots (using "hold on" or any other mechanism). However, the same effect can be achieved by replacing "geobubble" with "bubblechart" in the following way:
The following code achieves the desired outcome:
figure
gx = geoaxes("Basemap","streets");
hold on
bubblechart(bubbleLats, bubbleLons, bubbleSizes, "Parent", gx);
geoplot(regions);
geolimits([50 60], [-15 5]);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Geographic Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!