Error using geobasemap in subplot
23 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Cris LaPierre
il 26 Lug 2023
Modificato: Cris LaPierre
il 26 Lug 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 Commenti
Cris LaPierre
il 26 Lug 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.
Vedere anche
Categorie
Scopri di più su Geographic Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!