필터 지우기
필터 지우기

How to stop the first plot from overwriting the second plot in app.Panel when using Tiledlayout? "Hold on" does not work.

조회 수: 6 (최근 30일)
The below is my code, it should plot 5 graphs in one figure using the tiledlayout function. Each graph should have a red line and blue circles. If I run the below, without the app.Panel portion in the command line, I get the expected graph. However, when add in app.Panel so the plot shows up in my matlab app, I only get the second plot with the red line, the first plot with the blue circles is gone.
Anyone know a solution to this? Thanks!
x=1:1:10;
y=2:2:20;
x_values=1:3:30;
y_values=1:2:20;
t=tiledlayout(app.Panel,1,5);
for c=1:5
ax=nexttile(t);
plot(ax,x,y,'o', 'MarkerSize', 10, 'LineWidth', 2 ,'color','b');
hold on;
plot(ax, x_values, y_values, 'r', 'LineWidth', 2);
title(ax,'test');
xlabel(ax,'Setting Value'); % Add title for X axis
ylabel(ax,'Test Factor'); % Add title for Y axis
hold off;
end

채택된 답변

Cris LaPierre
Cris LaPierre 2024년 5월 6일
In App Designer, you must specify which axes to hold on by using the syntax hold(ax,___).
Try this
hold(ax,'on')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by