Setting geoplot longitude limits manually - changing aspect ratio

51 vues (au cours des 30 derniers jours)
Ariana
Ariana le 10 Avr 2024
Hi all!
I have a question about using geoplots. Is there a way of changing the aspect ratio and stretching it out?
My plot works great, but the longitude that automatically is used for the x axis is way too large of a range - my actual data is right in the center. I would love to be able to zoom in to a specific longitude range, so that the details of my data could be clearer. I've tried using geolimits, which I saw from another post on this topic, as well as using the function myresizefcn from another post, but neither of them seemed to work. Please help!
Here is my code:
datetime = rates(:,1);
Latitude = rates(:,2);
Longitude = rates(:,3);
rates = rates(:,4);
gx = geoaxes;
geolimits([52.9569 80.0627], [0, 45]); %this doesn't seem to work!!
geoplot(gx, Latitude, Longitude,'LineWidth', 4, 'color', 'k');
gx.LatitudeAxis.FontSize = 12;
gx.LatitudeAxis.Label.FontSize = 20;
gx.LatitudeAxis.Label.FontWeight = 'bold';
gx.LatitudeAxis.TickValues = [45 50 55 60 65 66.5 70 75 80];
gx.LatitudeAxis.TickLabels = {'45°N', '50°N', '55°N', '60°N', '65°N', 'Arctic Circle', '70°N', '75°N', '80°N'};
gx.LatitudeAxis.FontWeight = 'bold';
gx.LongitudeAxis.FontSize = 12;
gx.LongitudeAxis.Label.FontSize = 20;
gx.LongitudeAxis.Label.FontWeight = 'bold';
gx.LongitudeAxis.FontWeight = 'bold';
gx.LineWidth = .5;
gx.GridColor = 'k';
gx.GridAlpha = .5;
figure(1)
hold on
geobasemap('satellite')
colormap parula
c = colorbar;
c.FontSize = 12;
c.FontWeight = 'bold';
geoscatter(Latitude,Longitude, 25, rates, 'filled');
c.Label.String = 'data units)';
c.Label.FontWeight = 'bold';
c.Label.FontSize = 20;
c.Label.Rotation = 270;
c.Label.Position = [4.5 50 0];
o = 1;
And I've attached my dataset! (when you download it it might show up as rates1, sorry about that!)
Here is the figure I get:
My longitude data range is in between 0 and like 45 degrees, and that's what I'd like it to be set to so the area inbetween that is stretched out and you can see the details more clearly.
Thank you all in advance!

Réponse acceptée

Kojiro Saito
Kojiro Saito le 11 Avr 2024
Note
The geolimits function typically uses wider limits than the limits you specify to maintain the aspect ratio of the map.
The upper and lower limit would be changed for adjusting aspect ratio of map.
So, you need to specify Position of figure so that the map becomes a vertical rectangle.
matStr = load('rates.mat');
rates = matStr.rates1;
datetime = rates(:,1);
Latitude = rates(:,2);
Longitude = rates(:,3);
rates = rates(:,4);
figure("Position", [100 200 650 800]) % Added
gx = geoaxes;
geolimits([52.9569 80.0627], [0 45]);
geoplot(gx, Latitude, Longitude,'LineWidth', 4, 'color', 'k');
gx.LatitudeAxis.FontSize = 12;
gx.LatitudeAxis.Label.FontSize = 20;
gx.LatitudeAxis.Label.FontWeight = 'bold';
gx.LatitudeAxis.TickValues = [45 50 55 60 65 66.5 70 75 80];
gx.LatitudeAxis.TickLabels = {'45°N', '50°N', '55°N', '60°N', '65°N', 'Arctic Circle', '70°N', '75°N', '80°N'};
gx.LatitudeAxis.FontWeight = 'bold';
gx.LongitudeAxis.FontSize = 12;
gx.LongitudeAxis.Label.FontSize = 20;
gx.LongitudeAxis.Label.FontWeight = 'bold';
gx.LongitudeAxis.FontWeight = 'bold';
gx.LineWidth = .5;
gx.GridColor = 'k';
gx.GridAlpha = .5;
figure(1)
hold on
geobasemap('satellite')
colormap parula
c = colorbar;
c.FontSize = 12;
c.FontWeight = 'bold';
geoscatter(Latitude,Longitude, 25, rates, 'filled');
c.Label.String = 'data units)';
c.Label.FontWeight = 'bold';
c.Label.FontSize = 20;
c.Label.Rotation = 270;
c.Label.Position = [4.5 50 0];
hold off
o = 1;

Plus de réponses (0)

Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by