Error using geobasemap in subplot
조회 수: 23 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Cris LaPierre
2023년 7월 26일
편집: Cris LaPierre
2023년 7월 26일
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
Cris LaPierre
2023년 7월 26일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!