Saving a figure with multiple graphs
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all, Assume that I have the following plot: fig = plot(t,xt, t, yt);
Now, if i want to save such a plot using saveas(fig,'ddddd.jpg'), I get into trouble. It seems to be because fig is now a 2x1 handle which probably saveas is not supporting ( I am not sure though). I have tried hgsave. But, the jpg file was not opening. Any comments?
0 comentarios
Respuestas (1)
Matt Kindig
el 17 de Abr. de 2013
saveas() takes a figure handle. The output of a plot() command is a line handle (or a 2x1 vector of line handles, as you have it). Instead, do this:
plot(t,xt, t, yt);
fig = gcf;
saveas(fig, 'dddddd.jpg');
This should work.
2 comentarios
Matt Kindig
el 18 de Abr. de 2013
Editada: Matt Kindig
el 18 de Abr. de 2013
Payam, I think you are confused as to what 'fig' is. The handle 'fig' (which I have get set to the output of the gcf() function), is a handle to a figure, which doesn't have those properties at all.
Rather, you need to set the output of the plot() command (which outputs a line handle with properties such as 'lineWidth', 'MarkerSize', etc.) to a variable. Such as:
h = plot(t, xt, t, yt);
% h will be a 2x1 vector of LINE (not figure) handles
set(h(1), 'lineWidth', 2, 'MarkerSize, 5, ...); %set first line properties
set(h(2), 'lineWidth', 5, 'MarkerSize', 10, ...); %set second line properties
%you can also set a bunch of line handles to the same properties, using:
set(h,'lineWidth', 3, 'MarkerSize', 8, ....);
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!