相关疑难解决方法(0)

如何消除子图和周围的差距

我在一个图中绘制了两个子图(2x1).我想删除两个子图之间的所有间距,并删除顶部子图的xlable和xlabel刻度.此外,我试图删除子图外的所有间距.我试试

set(gca, 'LooseInset', get(gca,'TightInset'))
Run Code Online (Sandbox Code Playgroud)

但它不起作用.现在我手动删除这些边距和标签,我需要处理60个数字并且手动执行所有这些操作非常耗时.有更好的方法吗?谢谢.

我也尝试了subtightplot,它有助于减少所有边距,但xlabel和ylabel也被剪切

margins=[0 0];
t = 0:0.01:10;
y1 = sin(t);
y2 = cos(t);
h1 = subtightplot(2,1,1, margins);
plot(t, y1);
ystr = {'sin(x)','(dimensionless)'}
hy1 = ylabel(ystr);
set(gca, 'fontsize', 14);
set(hy1, 'fontsize', 14);
set(gca, 'XTickLabel', [],'XTick',[])

h2 = subtightplot(2,1,2,margins);
plot(t, y2, 'r-o');
hx2=xlabel('frequency');
hy2=ylabel('amplitude');
set(gca, 'fontsize', 14);
set(hx2, 'fontsize', 14);
set(hy2, 'fontsize', 14);
Run Code Online (Sandbox Code Playgroud)

我也尝试了subplot_tight,但情况更糟

matlab margins subplot

10
推荐指数
1
解决办法
2万
查看次数

在保留标题和标签的同时删除子图中的死角

嗨,我在matlab中遇到问题,我想创建一个包含10个子图的图形。在2X5方向。但是问题是我想减少它们之间的死区面积。我还需要保留标题,第一行图像为xlabel,第二行图像为xlabel(only)。不需要ylabel。

到现在为止,我已经完成了此代码(对于第一行):一旦确定了第一行,第二行应该是小菜一碟。

close all

figure,set(gca,'Color','none')
subplot(2,5,1);subplot('Position',[0.02 0.51  0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
imshow(I);hold on; axis off;
contour((BW(:,:,1)), [0 0], 'r','LineWidth',2);
hold off;title('1st curve','FontSize',12);xlabel('(a)','FontSize',12)
subplot(2,5,2);subplot('Position',[0.215 0.51  0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
imshow(I);hold on; axis off;
contour((BW(:,:,2)), [0 0], 'r','LineWidth',2);
hold off;title('2nd curve','FontSize',12);xlabel('(b)','FontSize',12)
subplot(2,5,3);subplot('Position',[0.410 0.51  0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
imshow(I);hold on; axis off;
contour((BW(:,:,3)), [0 0], 'r','LineWidth',2);
hold off;title('3rd curve','FontSize',12);xlabel('(c)','FontSize',12)
subplot(2,5,4);subplot('Position',[0.605 0.51  0.18 0.45]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
imshow(I);hold on; axis off;
contour((BW(:,:,4)), [0 0], 'r','LineWidth',2);
hold off;title('4th …
Run Code Online (Sandbox Code Playgroud)

matlab plot image subplot

5
推荐指数
1
解决办法
723
查看次数

标签 统计

matlab ×2

subplot ×2

image ×1

margins ×1

plot ×1