gpt4 book ai didi

matlab:绘图区域在数据结束后继续

转载 作者:行者123 更新时间:2023-12-02 04:51:42 26 4
gpt4 key购买 nike

我在 Matlab 中有一个简单的绘图,但正如您从屏幕截图中看到的那样。数据系列结束后,图表右侧有大量空白。

enter image description here

知道如何摆脱这个空白区域并使情节恰到好处地延伸到图形的边缘吗?这是我的代码:

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

最佳答案

这通常对我有用:

axis tight;
xlim('auto');

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

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

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

关于matlab:绘图区域在数据结束后继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18723987/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com