0

在应用程序设计器(MATLAB)中,我有两个要显示在彼此之上的图表。这就是我所做的:

plot(app.UIAxes,(1:length(app.var.OEch))/app.var.OE_Fs,app.var.OEch,'Color',[0,0.7,0.9])

st=app.var.st;
hold on
for ss = 1:length(st)
plot(app.UIAxes,[st(ss);st(ss)],[50;250], 'r');
end
hold off

如果我要摆脱 for 循环中的 app.UIAxes,它会工作并分别绘制两个图,但我希望它能够在 UIAxes 上绘制它。目前,我只看到一个白屏,如果我要运行它,我的绘图应该是。

4

1 回答 1

1

替换hold onhold(app.UIAxes, 'on');

hold(app.UIAxes, 'on');
for ss = 1:length(st)
    plot(app.UIAxes,[st(ss);st(ss)],[50;250], 'r');
end
hold(app.UIAxes, 'off');

%Add drawnow command (just in case...).
drawnow

您需要使用hold(app.UIAxes, 'on');, 的原因是hold on应用“当前轴”,并且在 GUI 应用程序中,焦点可能会更改为其他轴(当您有多个轴时)。

使用示例hold on
在此处输入图像描述

使用示例hold(app.UIAxes, 'on')
在此处输入图像描述

于 2019-06-10T16:16:10.387 回答