How to draw the map bounding box over the grid using the Mapping Toolbox?

9 次查看(过去 30 天)
Greetings all,
I have been trying to make my map pretty by changing the line width of my grid.
And when I do that, the grid draws on the top of the map's bounding box.
latLim = [-53.7 -52];
lonLim = [-41 -39.2];
figure
h = worldmap(latLim, lonLim);
setm(gca, 'FontSize', 20);
setm(gca, 'GLineWidth', 2);
set(gca, 'LineWidth', 2);
And the result is:
Not very pretty or "professional". 😔
I tried:
set(gca ,'Layer', 'Top')
No success.
I tried setm and computer says no.
Would you have any idea how on earth can we tell Matlab to draw the bounding box over the grid?
Thank you in advance.

回答(1 个)

Prince Sachdeva
Prince Sachdeva 2020-6-18
I understand that you want to draw a bounding box over the grid, you can update the code as shown below:
latLim = [-53.7 -52];
lonLim = [-41 -39.2];
figure
h = worldmap(latLim, lonLim);
axis('on'); % this is the KEY line
setm(gca, 'FontSize', 20);
set(gca ,'Layer', 'Top');
set(gca, 'LineWidth', 5);
setm(gca, 'GLineWidth', 2);
  2 个评论
Benoit Espinola
Benoit Espinola 2020-6-18
This is a good atempt. However it does not put the map's bounding box on the top, it just adds a box around the map without alligning it to the map's grid. This mismatch makes the whole thing visually disturbing and not aestetic. I would not use such a figure in a professional publication.
The image above has been generated using your code. Note the south-most area of the figure, the grid and the box are not aligned.
I believe the issue is within the maping toolbox code itself. The code does not generate axes per se, but draws the whole thing from scratch and hides the default axes. Somewhere in the code, the grid is drawn after the map's bounding box.
Benoit Espinola
Benoit Espinola 2020-6-18
编辑:Benoit Espinola 2020-6-18
I also tried your approach with different lat-lon limits. And it is pretty clear how this could be an issue for regions covering large latitude ranges.
Here is an "extreme" example:
figure
worldmap('world');
axis('on'); % this is the KEY line
setm(gca, 'FontSize', 20);
set(gca ,'Layer', 'Top');
set(gca, 'LineWidth', 5);
setm(gca, 'GLineWidth', 2);
The above code yields to:
Another example:
figure
worldmap('antarctica');
axis('on'); % this is the KEY line
setm(gca, 'FontSize', 20);
set(gca ,'Layer', 'Top');
set(gca, 'LineWidth', 5);
setm(gca, 'GLineWidth', 2);
Yields to:
Note that I only changed the map's lat-lon limits and projection. The rest of the code is identical to yours.
As a side note for Mathworks developpers: 90ºS is a point, that circle near 90ºS is confusing.

请先登录,再进行评论。

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by