【问题标题】:matlab: plot area continues after data endsmatlab:数据结束后绘图区域继续
【发布时间】:2013-09-14 11:05:42
【问题描述】:

我在 Matlab 中有一个简单的绘图,但您可以从屏幕截图中看到。数据序列结束后,图表右侧有很多空白。

知道如何摆脱这个空白并使情节直接到图形的边缘吗?这是我的代码:

Plotx = plot(x);
hold on
PlotState = plot(Y);

set(Plotx,'Color','black','LineWidth',2.5);
set(PlotState,'Color','red','LineWidth',2.5);

set(gca, 'XTick',(1:3:62))
labels = time;
set(gca,'XTickLabel',labels(1:3:62))

grid on

【问题讨论】:

  • 这个answer 展示了如何移除任意一侧的边框。

标签: matlab graph plot figure


【解决方案1】:

这通常对我有用:

axis tight;
xlim('auto');

您必须选择您的图,返回控制台并使用这些命令,以便它们影响最后一个活动图。

编辑:上面的行应该会自动使您的图表轴非常紧贴您的数据。想要更精细的控制,不妨define the axis limits manually

 axis([xmin,xmax,ymin,ymax])

【讨论】:

    【解决方案2】:

    我找到了解决方案。我手动调整x轴的限制,使用:

    set(gca,'XLim',[0 63])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-16
      • 1970-01-01
      • 1970-01-01
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多