How could I plot geobubble and geoplot in the same figure?

23 ビュー (過去 30 日間)
Thanaboon Soasawang
Thanaboon Soasawang 2020 年 6 月 10 日
コメント済み: Feng Cheng 2021 年 4 月 22 日
I wrote the code
% this code is shorten from my full version because importing steps is too long and irrelevant for this question
Data = struct; % this struct array contains earthquake data in form of 1*1 struct with 8 fields,
% 3 from all fields are latitude,longitude and magnitude data
shapefilename = 'myflielocation\myfile.shp'; % this file contain fault line to plot with earthquake events location
S = shaperead(shapefilename, 'UseGeoCoords', true);
fig = figure;
geoaxes('NextPlot','add');
geobubble(fig,Data.lat,sortData.lon,sortData.mag,'Basemap', 'grayterrain');
geoplot(fig,S.lat,S.Lon);
After tried several times, The message "Adding GeographicBubbleChart to geoaxes is not supported Turn hold off." always show in the command window
It is possible to plot geobubble and use hold on or similar fucntion to use geoplot function within the same figure?
====================
The cause of this question is I want to plot line and bubbles data in the same figure.
Before, I have tried following steps in
by replacing some codes
han = figure;
fg1 = geobubble(han,lat,lon,weight,'Basemap', 'grayterrain');
geolimits(f1, [LatLimit_a LatLimit_b], [LonLimit_a LonLimit_b]);
ax = geoaxes(eq,'Position',get(fg1,'Position'));
gg = geoplot(ax,lat,lon);
alpha(ax, 0.2);
ax.Visible = 'off';
geolimits(ax, [LatLimit_a LatLimit_b], [LonLimit_a LonLimit_b]);
The problem is the plot data is adjustable in figure window, not fix like using hold command in normal plot.
If my first question is impossible. Any alternating way exist? I need fixed data and axes.
Thank you.
  1 件のコメント
David Kelly
David Kelly 2020 年 8 月 13 日
I am also looking to plot lines and other data over my geobubble plot. DId you find any solutions?
Thanks!!

サインインしてコメントする。

回答 (1 件)

jonas
jonas 2020 年 8 月 13 日
This is not a very good solution, but its something. It seems you cannot use plotm() etc. from the mapping toolbox in the same axes as a geobubble() plot. My solution was to overlay a second axes. For some reason MATLAB returns an error related to "Nextplot" if you add a map axes after geobubble, unless you first add a normal axes.
So, after a lot of experimenting this is the result. Note that the second axis is not perfectly aligned with the geobubble for unknown reason. You can play around with the position of the figure and the second axis to make it perfectly aligned.
tsunamis = readtable('tsunamis.xlsx');
tsunamis.Cause = categorical(tsunamis.Cause);
ax(1) = geobubble(tsunamis,'Latitude','Longitude', ...
'SizeVariable','MaxHeight','ColorVariable','Cause')
fig = gcf;
fig.Position = [100 100 900 500]
%for some reason you have to add this invisible axes before axesm
axes('visible','off')
ax(2) = axesm('MapProjection','mercator',...
'MapLatLimit',ax(1).LatitudeLimits,...
'MapLonLimit',ax(1).LongitudeLimits);
ax(2).Position = ax(1).Position
plotm(tsunamis{:,1},tsunamis{:,2},'o')
ax(2).Color = 'none';
  2 件のコメント
David Kelly
David Kelly 2020 年 8 月 13 日
How cool. Thanks for the response Jonas!!!
Feng Cheng
Feng Cheng 2021 年 4 月 22 日
It looks like the overlap points are a little off from the actual point?

サインインしてコメントする。

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by