フィルターのクリア

Setting manually limits in geoplot

29 ビュー (過去 30 日間)
Vinícius Ludwig Barbosa
Vinícius Ludwig Barbosa 2021 年 8 月 19 日
Is there a way to set precisely the limits of a geoplot, e.g.
gx = geoaxes;
geolimits([-45 45], [-180 180]);
and "lock" this ratio as much as possible no matter how I resize the figure window?

採用された回答

Dave B
Dave B 2021 年 8 月 20 日
This is a somewhat crazy approach, and won't work for very really extreme figure sizes. geoaxes is trying to fill the window, and maintain a fixed lat/long aspect ratio, but doesn't appear to have any sort of PlotBoxAspectRatio. I fudged the numbers a tad below because it was effective on my display, you might have to play a bit with the values.
gx = geoaxes;
geolimits([-45 45], [-180 180]);
%ar=90/360;
ar=90/320;
gx.Units='pixels';
f=gcf;
f.SizeChangedFcn=@(~,~)myresizefcn(gx, f, ar);
myresizefcn(gx,f,ar)
function myresizefcn(gx,f,ar)
if (f.Position(4)/f.Position(3))<ar
% wide: height is constraint
gx.Position(4)=f.Position(4) * .8;
gx.Position(3)=gx.Position(4) / ar;
% centering:
gx.Position(1)=f.Position(3)/2 - gx.Position(3)/2;
gx.Position(2)=f.Position(4)/2 - gx.Position(4)/2;
% re-nudge limits
geolimits([-45 45], [-180 180]);
else
% tall: width is constraint
gx.Position(3)=f.Position(3) * .8;
gx.Position(4)=gx.Position(3) * ar;
% centering:
gx.Position(1)=f.Position(3)/2 - gx.Position(3)/2;
gx.Position(2)=f.Position(4)/2 - gx.Position(4)/2;
% re-nudge limits
geolimits(gx,[-45 45], [-180 180]);
end
end
  1 件のコメント
Vinícius Ludwig Barbosa
Vinícius Ludwig Barbosa 2021 年 8 月 20 日
It works perfectly! Thanks @Dave B
Minor fix at myresizefcn, last line in else statement:
geolimits([-45 45], [-180 180]); %previously geolimits(gx,[-45 45], [-180 180]);

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by