global legend in subplot

102 visualizaciones (últimos 30 días)
Davindra Usov
Davindra Usov el 1 de Feb. de 2023
Comentada: Davindra Usov el 22 de Mzo. de 2023
Hello,
I am trying to place my global legend at south east location in my subplot but to no avail. My code is as follows
for t = 1:21
subplot(3,7,t)
plot(x,y)
hold on
plot(x1,y1)
legend('old','new','Location','southeastoutside')
end
This places the legends at the south east location outside of each plot, but I want only one global legend for the whole subplot, not multiple individual legends
any suggestions will be much appreciated

Respuesta aceptada

Voss
Voss el 1 de Feb. de 2023
That cane be done using tiledlayout instead of subplot.
x = 1:10;
y = 1:10;
x1 = 1:10;
y1 = 2:11;
tiledlayout(3,7)
for t = 1:21
nexttile
plot(x,y)
hold on
plot(x1,y1)
end
legend('old','new','Location','southeastoutside')
  1 comentario
Davindra Usov
Davindra Usov el 22 de Mzo. de 2023
worked perfectly. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by