How to link geographic axes limits

18 次查看(过去 30 天)
I have to use multiple axis to superpose two geoscatter on a map (to be able to set one colormap for each kind of data on the same figure), and I'm used to the linkaxes function when I do this kind of stacking with more traditionnal axes. But it seems to be impossible to do as simply for geographic axes... Does anyone know how to do this ?
This is how I do with non-geographical axes :
cmap1 = 'jet'; cmap2 = 'winter'; %for example
x1 = 1:10; y1 = x1; A1 = 10; C1 = 1:length(x1);
x2 = 0:9; y2 = 3*x2;A2 = 10; C2 = 1:length(x2);
figure()
ax1 = axes;
scatter(x1,y1,A1,C1)
ax2 = axes;
scatter(x2,y2,A2,C2);
ax2.Visible = 'off'; % Here we have our two axes stacked
linkaxes(ax1,ax2) % what I'm used to
colormap(ax1,cmap1)
colormap(ax2,cmap2)
Shoud I rather use Mapping Toolbox functions ?

回答(1 个)

Vinayak
Vinayak 2024-1-4
Hi Damien
The function 'linkaxes' does not support 'geoaxes'.
You may try this workaround by using the 'linkprop' function. There may be lag while rendering such a plot. This is due to the high computational requirements in geoaxes objects.
lat1 = rand(10, 1) * 10;
lon1 = rand(10, 1) * 10;
lat2 = rand(10, 1) * 10;
lon2 = rand(10, 1) * 10;
figure;
% Create geoaxes
ax1 = geoaxes;
ax2 = geoaxes;
% Plot initial data
geoscatter(ax1, lat1, lon1);
colormap(ax1, 'jet');
geoscatter(ax2, lat2, lon2);
colormap(ax2, 'winter');
ax2.Visible = 'off';
linkprop([ax1, ax2], {'MapCenter', 'ZoomLevel', 'LatitudeLimits', 'LongitudeLimits'});
I would suggest using single geoaxes to plot values and customize them using Marker Properties.
lat1 = rand(10, 1) * 10;
lon1 = rand(10, 1) * 10;
lat2 = rand(10, 1) * 10;
lon2 = rand(10, 1) * 10;
figure;
% Create geoaxes
ax1 = geoaxes;
% Plot initial data
geoscatter(ax1, lat1, lon1, 'blue');
hold on;
geoscatter(ax1, lat2, lon2, 'yellow');
Please refer to this answer by Adam Danz that talks about overlaying geoaxes with normal axes.

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by