我正在制作一系列世界地图。我希望重新调整垂直轴和水平轴的比例。目前,垂直轴从-80到80(以20为增量),水平轴从0到360(以50为增量)。
我希望将垂直轴设置为-70至70(以20为增量),将水平轴设置为0至360(以30为增量)。
这是我代码中地图颜色的一部分,以及排列颜色条。
function custom_map=mycolormap
blues = [linspace(0, 1, 100);
linspace(0, 1, 100);
linspace(1, 1, 100);]';
reds = [linspace(1, 1, 100);
linspace(1, 0, 100);
linspace(1, 0, 100);]';
custom_map = [blues; reds];
caxis([-6,6]);
ylabel(colorbar, 'SSTA (°C)');
答案 0 :(得分:0)
可以使用xlim,ylim,xticks和yticks进行操作。在我看来,您应该做的是在函数末尾插入以下行:
xMin = 0;
xMax = 360;
xStep = 30;
yMin = -70;
yMax = 70;
yStep = 20;
xlim([xMin, xMax]); % Sets the limit of the x axis
ylim([yMin, yMax]); % Sets the limit of the y axis
xticks(xMin:xStep:xMax); % Sets the increments of the x axis
yticks(yMin:yStep:yMax); % Sets the increments of the y axis
据我尝试,这应该可行。可以随意遵循不同的命名约定来命名变量,但是最好避免在代码中使用幻数,特别是因为其中的幻数会多次出现。
希望这会有所帮助。