- 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 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2023-5-26
回答: MathWorks Support Team
2023-6-1
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?
采纳的回答
MathWorks Support Team
2023-5-26
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!