【问题标题】:How to readjust caxis on all subplots?如何调整所有子图上的 x 轴?
【发布时间】:2013-11-21 01:48:09
【问题描述】:

所以我有两个具有不同 caxis 值的子图。有没有办法使用 caxis([-2 2]) 以便它可以重新调整所有子图的 caxis ?有一个函数可以生成每个图,我希望所有图都具有相同的 caxis 以便于比较。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    假设您有一个包含子图的图形的句柄,您可以执行以下操作:

    subplots = get(fig_handle,'Children'); % Get each subplot in the figure
    for i=1:length(subplots) % for each subplot
        caxis(subplots(i),[-2,2]); % set the clim
    end
    

    如果您没有该图的句柄,请改用gcf

    【讨论】:

      【解决方案2】:

      您可以将图中所有子图的颜色限制设置为其现有颜色限制的范围,使用:

      S = findobj(gcf,'Type','Axes');
      C = cell2mat(get(S,'Clim'));
      C = [min(C(:,1)) max(C(:,2))];
      set(S,'CLim',C);
      

      或者用一条令人震惊的线:

      set(findobj(gcf,'Type','Axes'),'CLim',max(cell2mat(get(findobj(gcf,'Type','Axes'),'Clim'))*diag([-1 1]))*diag([-1 1]))
      

      【讨论】:

        猜你喜欢
        • 2019-01-28
        • 1970-01-01
        • 2020-11-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-16
        • 2020-08-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多