- 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!