How do I add polygons to a map created with "geobubble"?

7 ビュー (過去 30 日間)
MathWorks Support Team
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
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:
  1. Explicitly create a set geographic axes (using "geoaxes").
  2. 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".
  3. Add extra plots with "geoplot".
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 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by