【问题标题】:Put contour plots of for non-overlapping data ranges on a single set of axes?将非重叠数据范围的等高线图放在一组轴上?
【发布时间】:2015-02-25 17:45:24
【问题描述】:

我想将两个数据集的等高线图放在具有相同颜色条的相同轴上。数据的 X 和 Y 范围不重叠,而是物理上相邻。

这是两个这样的轮廓图的简化示例,我想将它们组合在相同的轴上:

   %generate 1st sample dataset
   [x1,y1]=meshgrid(-3:3);
   v1=peaks(x1,y1)

   %generate 2nd sample dataset & move it so it is physically adjacent to 
   %1st dataset
   [x2,y2]=meshgrid(-4:4);
   v2=peaks(x2,y2)
   x2=8+x2;

   figure(1)
   contourf(x1,y1,v1)
   colormap(jet)
   colorbar('EastOutside')
   xlabel('x (mm)')
   ylabel('y (mm)')

   figure(2)
   contourf(x2,y2,v2)
   colormap(jet)
   colorbar('EastOutside')
   xlabel('x (mm)')
   ylabel('y (mm)')

这会产生以下图

我尝试使用以下方法将两个示例数据集放在相同的轴上:

    figure(3)
    contourf(x1,y1,v1)
    colormap(jet)
    hold on

   contourf(x2,y2,v2)
   colormap(jet)
   hold off

使用典型的“坚持”不起作用...建议??

【问题讨论】:

    标签: matlab contourf


    【解决方案1】:

    第二个等高线图不可见,因为 x 轴范围太小。在hold off之后将以下命令添加到您的脚本中

    xlim([-3 12]);
    ylim([-4 4]);
    

    这将产生以下情节

    【讨论】:

      猜你喜欢
      • 2014-08-09
      • 1970-01-01
      • 2010-10-12
      • 2013-10-28
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 2013-12-29
      • 2023-02-04
      相关资源
      最近更新 更多