Saving a figure with multiple graphs
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Matt Kindig
le 17 Avr 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 commentaires
Matt Kindig
le 18 Avr 2013
Modifié(e) : Matt Kindig
le 18 Avr 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, ....);
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!