How do I combine two or more graphs into one file

1 visualización (últimos 30 días)
Evan Tannler
Evan Tannler el 10 de Abr. de 2019
Respondida: ag el 25 de Sept. de 2024
I have 3 Graphs plotted, labeled, and saved. I know there are subplots to create with data but can not figure out how to create a set similar to subplots with already created graphs. I just want to combine the three graphs I have saved seperately all together into one figure with their own labels.
  1 comentario
Evan Tannler
Evan Tannler el 17 de Abr. de 2019
I am just trying to figure out how to combine these three figures into one file.combine.png

Iniciar sesión para comentar.

Respuestas (1)

ag
ag el 25 de Sept. de 2024
Hi Evan,
To plot multiple graphs on the same figure window, you can use the "hold on" command.
The below code snippet demonstrate how to achieve this using dummy data:
% Data for plotting
x = linspace(0, 2*pi, 100);
y1 = sin(x);
y2 = cos(x);
% First graph
figHandle = figure; % Open a new figure window
plot(x, y1);
hold on
% Second graph
plot(x, y2);
xlabel('x');
legend('sin(x)', 'cos(x)'); %add legends
title('Waves');
To save the figure, you can use the below command
exportgraphics(figHandle,"myplot.jpg") % Save a JPEG
For more details, please refer to the following MathWorks documentation: Hold - https://www.mathworks.com/help/matlab/ref/hold.html
Hope this helps!

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by