Matlab 地图的主分划和次分划?

Matlab 地图的主分划和次分划?,matlab,plot,matlab-figure,geo,gridlines,Matlab,Plot,Matlab Figure,Geo,Gridlines,我已经创建了以下地图,它有一个统一的灰色网格,子午线和平行线的间隔均为1°: 我还希望子午线和平行线更厚,每5°间隔为黑色(同时保持1°网格),以便网格线与纬度和经度标签匹配,如下所示: 我知道MATLAB已经为标准2D绘图提供了支持,我过去也使用过。然而,据我所知,地图没有这个功能 我认为可以通过访问贴图对象属性(使用或)并为子午线和平行线的特定子集指定黑色属性(使用)来实现我想要做的事情。也许函数或函数可以处理这个问题,但我不确定 实际上,我不知道怎么做,因为我对地图没有任何经验。我真的

我已经创建了以下地图,它有一个统一的灰色网格,子午线和平行线的间隔均为1°:

我还希望子午线和平行线更厚,每5°间隔为黑色(同时保持1°网格),以便网格线与纬度和经度标签匹配,如下所示:

我知道MATLAB已经为标准2D绘图提供了支持,我过去也使用过。然而,据我所知,地图没有这个功能

我认为可以通过访问贴图对象属性(使用或)并为子午线和平行线的特定子集指定黑色属性(使用)来实现我想要做的事情。也许函数或函数可以处理这个问题,但我不确定

实际上,我不知道怎么做,因为我对地图没有任何经验。我真的很感激你的帮助

代码: 注意:此代码需要


这里有一个非常简单的技巧:在相同的
位置上做第二个
,然后在那里做你想要的主网格

从您的代码开始,进行一些修改(我结合了
axesm
gridm
):

然后制作第二个轴:

% get the position of the first axes
L = get(ha, 'Position');

% make a new axes in the same position
axes('Position', L)

axesm ('lambert',...
    'MapLonLimit', [-70 10],...
    'MapLatLimit', [30 70],...
    'MapParallels', [38.00555556 71.01111111],...
    'Frame', 'on',...
    'FLineWidth', 2,...
    'Grid', 'on',...
    'GLineStyle', '-',...
    'GLineWidth', 2,...
    'GColor', [.2 .2 .2], ...
    'MLineLocation', 5,...
    'MLabelLocation', 5,...
    'PLineLocation', 5,...
    'PLabelLocation', 5);

mlabel on;
plabel on;
axis off;
您将得到以下结果:

甚至不需要获取和设置位置,因为它们都将在默认位置创建;DR

使用稍微修改过的代码版本:

% Read vector features and attributes from shapefile.
landareas = shaperead('landareas.shp', 'UseGeoCoords', true);

% Define map axes and set map properties.
hAx = axesm ('lambert',...  <<<<<<<<<<<<<<<<<<<<<<<<< Change #1
    'MapLonLimit', [-70 10],...
    'MapLatLimit', [30 70],...
    'MapParallels', [38.00555556 71.01111111],...
    'Frame', 'on',...
    'FLineWidth', 1,...
    'Grid', 'on',...
    'GLineStyle', '-',...
    'GLineWidth', 0.1,...
    'GColor', [.7 .7 .7]);

% Display map latitude and longitude data.
geoshow(landareas, 'FaceColor', [1 1 .5], 'EdgeColor', [.3 .3 .3]);

% Toggle and control display of graticule lines.
hGrid = gridm(... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Change #2
  'MLineLocation', 1,... 
  'PLineLocation', 1);

% Change #3:
hGridCopy = copyobj(hGrid,hAx); 
set(hGridCopy,'Tag','oldGrid');  % We use this to hide the grid from handlem,
gridm(...                          so that it doesn't get found and deleted.
  'MLineLocation', 5,...
  'MLabelLocation', 5,...
  'PLineLocation', 5,...
  'PLabelLocation', 5,...
  'GColor',[0,0,0],...
  'GLineWidth',3);

% Toggle and control display of meridian labels.
mlabel on;

% Toggle and control display of parallel labels.
plabel on;

axis off;
然后,
hAx.Children
为我们提供以下信息:

ans=
30×1图形阵列:
文本(PLabel)
... 
文本(MLabel)
直线(平行)
线(子午线)
团体
补丁(框架)
从中我们了解到,每一条线的集合,即子午线和平行线,实际上是一个单独的对象,这意味着特定类型的所有线都必须具有完全相同的样式-不同于“传统的”次要和主要
网格
线(可能不同)。如果我们希望某些线不同,我们必须创建一个具有所需属性的新对象(线的子集)


现在,创建这些极坐标网格线的最简单方法是再次调用
gridm
,但遗憾的是,这会删除所有已绘制的网格。它是如何做到的
gridm
内部调用
handlem('grid')
,它查找带有
标记的图形对象,标记为
Parallel
Meridian
,找到的对象稍后将被删除并替换为具有新外观的对象。那我们该怎么办?当然,我们从
handlem
中“隐藏”网格(请参见
更改#3
;通过更改这些对象的
标记
属性)!然后我们创建另一个网格,就完成了。

确实存在一个StackExchange站点。有人可能会发现这很有用:如果您希望同时缩放两个轴,请使用。
% get the position of the first axes
L = get(ha, 'Position');

% make a new axes in the same position
axes('Position', L)

axesm ('lambert',...
    'MapLonLimit', [-70 10],...
    'MapLatLimit', [30 70],...
    'MapParallels', [38.00555556 71.01111111],...
    'Frame', 'on',...
    'FLineWidth', 2,...
    'Grid', 'on',...
    'GLineStyle', '-',...
    'GLineWidth', 2,...
    'GColor', [.2 .2 .2], ...
    'MLineLocation', 5,...
    'MLabelLocation', 5,...
    'PLineLocation', 5,...
    'PLabelLocation', 5);

mlabel on;
plabel on;
axis off;
% Read vector features and attributes from shapefile.
landareas = shaperead('landareas.shp', 'UseGeoCoords', true);

% Define map axes and set map properties.
hAx = axesm ('lambert',...  <<<<<<<<<<<<<<<<<<<<<<<<< Change #1
    'MapLonLimit', [-70 10],...
    'MapLatLimit', [30 70],...
    'MapParallels', [38.00555556 71.01111111],...
    'Frame', 'on',...
    'FLineWidth', 1,...
    'Grid', 'on',...
    'GLineStyle', '-',...
    'GLineWidth', 0.1,...
    'GColor', [.7 .7 .7]);

% Display map latitude and longitude data.
geoshow(landareas, 'FaceColor', [1 1 .5], 'EdgeColor', [.3 .3 .3]);

% Toggle and control display of graticule lines.
hGrid = gridm(... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Change #2
  'MLineLocation', 1,... 
  'PLineLocation', 1);

% Change #3:
hGridCopy = copyobj(hGrid,hAx); 
set(hGridCopy,'Tag','oldGrid');  % We use this to hide the grid from handlem,
gridm(...                          so that it doesn't get found and deleted.
  'MLineLocation', 5,...
  'MLabelLocation', 5,...
  'PLineLocation', 5,...
  'PLabelLocation', 5,...
  'GColor',[0,0,0],...
  'GLineWidth',3);

% Toggle and control display of meridian labels.
mlabel on;

% Toggle and control display of parallel labels.
plabel on;

axis off;
% Change from this:
axesm ('lambert',...
% To this:
hAx = axesm ('lambert',...