【问题标题】:How to have a common label for all x and y axes in case of subplots?在子图的情况下,如何为所有 x 轴和 y 轴设置一个公共标签?
【发布时间】:2017-07-30 10:58:30
【问题描述】:

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

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

对于所有这些子图,我只需要一个 x-label 和一个 y-label。这个怎么做?另外如何将图例插入所有子图?

【问题讨论】:

    标签: matlab matlab-figure axis-labels axes subplot


    【解决方案1】:

    您可以使用 FileExchange 中的suplabel 为所有子图组合 xy 标签。

    示例:

    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');
    

    输出:


    使用suplabel时,有时你必须最大化图形窗口才能看到xlabel

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-22
      • 2022-12-08
      • 1970-01-01
      • 1970-01-01
      • 2020-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多