Error using geobasemap in subplot
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to plot some geolocated data with geoscatter as below:
geobasemap grayterrain
geolimits([35.79 40],[-124.8552 -119.3342]);
geoscatter(lat_stn, lon_stn, data_sum, data_sum, 'filled');
clim([0, 80]);
colorbar;
The above code works perfectly well and plots the data in a given basemap.
However, when I try to plot the exact above thing in a subplot I get some errors:
subplot (1, 2, 2)
geobasemap grayterrain
geolimits([35.79 40],[-124.8552 -119.3342]);
geoscatter(lat_stn, lon_stn, data_sum, data_sum, 'filled');
clim([0, 80]);
colorbar;
The error I get is:
Error using geobasemap>parseInputs
Unable to use geobasemap. Current axes or chart is not geographic.
Error in geobasemap (line 30)
[gx, basemap, usingBasemapSyntax] = parseInputs(varargin);
Error in spatial_madis_model_comparison_geobubble (line 94)
geobasemap grayterrain
Could you please advise how to fix this issue?
0 Kommentare
Antworten (1)
Cris LaPierre
am 26 Jul. 2023
Bearbeitet: Cris LaPierre
am 26 Jul. 2023
subplot creates a cartesian axes in the current position. Since you call geobasemap and geolimits before geoscatter, they attemp to operate on the cartesian axes, which is not allowed.
Try changing the order of your code so that you call geoscatter first, which does create a geographic axes, and then geolimits and geobasemap
subplot(1,2,2)
lat = [42.3501 42.3598 42.3626 42.3668 42.3557];
lon = [-71.0870 -71.0662 -71.0789 -71.0801 -71.0662];
geoscatter(lat,lon,"filled")
geolimits([42.3456 42.3694],[-71.0930 -71.0536])
geobasemap grayterrain
clim([0, 80]);
colorbar;
4 Kommentare
Cris LaPierre
am 26 Jul. 2023
This is the documented behavior of geolimits.
The geolimits function typically uses wider limits than the limits you specify to maintain the aspect ratio of the map.
Siehe auch
Kategorien
Mehr zu Geographic Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!