How to change the font size of a map axes (created using the Mapping toolbox) keeping the whole plot within the figure?

12 views (last 30 days)
Greetings,
I am trying to create a map for a publication and I would like to (easily) change the FontSize of my map axes and still have the axes printed inside the figure.
I am using the following code:
latLim = [-53.7 -52];
lonLim = [-41 -39.2];
figure
h = worldmap(latLim, lonLim);
setm(gca, 'FontSize', 20);
This code yields to this figure:
As you might notice, the longitudes are cropped.
PS: I want to keep the following:
get(gcf, 'position')
ans =
560 528 560 420
How can I make sure the map will be plotted in a correct manner inside this figure?

Accepted Answer

Ameer Hamza
Ameer Hamza on 15 Jun 2020
Try to reduce the axes size
latLim = [-53.7 -52];
lonLim = [-41 -39.2];
figure
h = worldmap(latLim, lonLim);
setm(gca, 'FontSize', 14);
h.Position(4) = h.Position(4)-0.1;
  3 Comments
Ameer Hamza
Ameer Hamza on 15 Jun 2020
Overall, I find Matlab graphics function to be convenient, however, I never used worldmap() before. I agree that the way worldmap is created, is a real mess. I don't think there is an easy way to rotate the labels. Following shows a workaround, but making any adjustment to the position of labels is quite difficult.
latLim = [-53.7 -52];
lonLim = [-41 -39.2];
figure
h = worldmap(latLim, lonLim);
setm(gca, 'FontSize', 14);
h.Position(4) = h.Position(4)-0.1;
lbls = findobj(h, 'Tag', 'PLabel');
[lbls.HorizontalAlignment] = deal('center');
[lbls.Rotation] = deal(-90);
for i=1:numel(lbls)
lbls(i).Position = lbls(i).Position - 15000;
end

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!