如果有子图,如何在所有x和y轴上使用通用标签? [英] How to have a common label for all x and y axes in case of subplots?

查看:91
本文介绍了如果有子图,如何在所有x和y轴上使用通用标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下循环获取子图:

for j=1:19;
    Aj=B(j,:);
    subplot(5,4,j);
    plot(Aj,h)
end

对于所有这些子图,我只需要一个x标签和一个y标签.这该怎么做?还有如何将图例插入所有子图?

解决方案

您可以使用 FileExchange 中的 suplabel ,以合并所有子图的 x y 标签. /p>

示例:

subplot(1,2,1);
plot(randperm(40)); hold on; plot(randperm(40));  %Plotting some random data
legend('show')   %To show the legend

subplot(1,2,2);
plot(randperm(40)); hold on; plot(randperm(40));  %Plotting some random data
legend('show')   %To show the legend

%Using suplabel from the FileExchange to give a single x and y label for all subplots
suplabel('Combined X label','x');
suplabel('Combined Y label','y');

输出:


有时,使用 xlabel . rel ="nofollow noreferrer"> suplabel .

I have used the following loop to get subplots:

for j=1:19;
    Aj=B(j,:);
    subplot(5,4,j);
    plot(Aj,h)
end

For all these subplots, I need to have only one x-label and one y-label. How to do this? Also how to insert legend to all the subplots?

解决方案

You can use suplabel from the FileExchange to have combined x and y label for all subplots.

Example:

subplot(1,2,1);
plot(randperm(40)); hold on; plot(randperm(40));  %Plotting some random data
legend('show')   %To show the legend

subplot(1,2,2);
plot(randperm(40)); hold on; plot(randperm(40));  %Plotting some random data
legend('show')   %To show the legend

%Using suplabel from the FileExchange to give a single x and y label for all subplots
suplabel('Combined X label','x');
suplabel('Combined Y label','y');

Output:


Sometimes you have to maximize the figure window to see the xlabel when using suplabel.

这篇关于如果有子图,如何在所有x和y轴上使用通用标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆