【发布时间】:2020-06-08 11:43:52
【问题描述】:
我正在尝试创建一个世界地图的子图(6 个图),我正在将选定的 shapefile 写入其中。我的问题在于子图的位置:它们相互覆盖。我从 stackoverflow 上的其他类似问题中了解到,这是因为轴以某种方式重叠。但我认为我已经创建了它们只是“并排”的职位(见下面的代码)。我试图使轴透明,但这似乎没有帮助。我的问题是:如何修改绘图位置,以免它们相互覆盖?
我正在使用的代码(删除了 shapefile 内容)是:
clc;
clear all;
%First create the positions for the subplots
handle1=subplot(3,2,1);
H1=get(handle1,'position');
h1pos=H1+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h1pos)
hold all
handle2=subplot(3,2,2);
H2=get(handle2,'position');
h2pos=H2+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h2pos)
handle3=subplot(3,2,3);
H3=get(handle3,'position');
h3pos=H3+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h3pos)
handle4=subplot(3,2,4);
H4=get(handle4,'position');
h4pos=H4+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h4pos)
handle5=subplot(3,2,5);
H5=get(handle5,'position');
h5pos=H5+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h5pos)
handle6=subplot(3,2,6);
H6=get(handle6,'position');
h6pos=H6+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h6pos)
subplot(3,2,1,'Position',h1pos)
text(0.02,0.98,'(a)','Units', 'Normalized', 'VerticalAlignment', 'Top');
%handle1=subplot(2,2,1);
%H1=get(handle1,'position');
%h1pos=H1+[-0.1,-0.1,0.1,0.1]; subplot(2,2,1,'Position',h1pos)
h=worldmap('world')
% borders('countries', 'Color', 'black')
subplot(3,2,2,'Position',h2pos)
text(0.02,0.98,'(b)','Units', 'Normalized', 'VerticalAlignment', 'Top')
h=worldmap('world')
% borders('countries', 'Color', 'black')
subplot(3,2,3,'Position',h3pos)
text(0.02,0.98,'(c)','Units', 'Normalized', 'VerticalAlignment', 'Top')
h=worldmap('world')
% borders('countries', 'Color', 'black')
subplot(3,2,4,'Position',h4pos)
text(0.02,0.98,'(d)','Units', 'Normalized', 'VerticalAlignment', 'Top')
h=worldmap('world')
% borders('countries', 'Color', 'black')
subplot(3,2,5,'Position',h5pos)
text(0.02,0.98,'(e)','Units', 'Normalized', 'VerticalAlignment', 'Top')
h=worldmap('world')
subplot(3,2,6,'Position',h6pos)
text(0.02,0.98,'(f)','Units', 'Normalized', 'VerticalAlignment', 'Top')
h=worldmap('world')
% borders('countries', 'Color', 'black')
% borders('countries', 'Color', 'black')
【问题讨论】:
标签: matlab handle subplot axes