Plots overlaying each other
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I've been struggling to get separate figures in one .mlx file. When I specify a figure(x) with hold on/hold off commands, and then start a new figure(x+i) with hold on/hold off, the later figure overlays the earlier one. Here is some sample code to illustrate my issue:
figure(1);
hold on
yyaxis left
title('plot 1')
plot(x,NH2O,'DisplayName','H2O','linewidth',2.0)
xlabel('x/L','fontsize',14,'fontweight','b','fontname','arial')
ylabel('H2O','fontsize',14,'fontweight','b','fontname','arial')
yyaxis right
plot(x,N1,'k-','linewidth',2.0)
plot(x,N2,'linewidth',2.0)
plot(x,N3,'linewidth',2.0)
ylim([0 inf])
ylabel('N','fontsize',14,'fontweight','b','fontname','arial')
legend('H2O','1','2','3')
xlim([0 1])
ylim([0 1])
hold off
figure(2);
hold on
title('plot 2')
xlim([0 1])
ylim([0 15])
xlabel('x/L','fontsize',14,'fontweight','b','fontname','arial')
ylabel('H2O','fontsize',14,'fontweight','b','fontname','arial')
plot(x,N1a, 'linewidth',2.0)
plot(x,N2a, 'linewidth',2.0)
hold off
0 comentarios
Respuestas (1)
Star Strider
el 13 de Ag. de 2021
The figure windows are on top of each other. Nothing is replaced. They just have to be moved to different positions.
The new positions are not visible in the online Run application, however they should work in your situation.
Try this —
x1 = 1:10;
y1 = rand(1,10);
figure
plot(x1, y1)
grid
x2 = 1:20;
y2 = randn(1,20);
figure
plot(x2, y2)
grid
fpos = get(gcf,'Position');
set(gcf, 'Position',fpos+[700 -700 0 0])
Experiment to get tifferent results.
.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!