help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to print (i.e., save to a file) just the plot you want, out of s


From: James Sherman Jr.
Subject: Re: How to print (i.e., save to a file) just the plot you want, out of several?
Date: Tue, 12 Jun 2012 08:14:23 -0400

On Tue, Jun 12, 2012 at 8:05 AM, Mark Lytle <address@hidden> wrote:
To all,

I have an Octave program that outputs 5 plots labelled figure 1 through figure 5.  If i want to save figure 3 to a .png file, how do I do it?   I've tried deleting all of the plots from the workspace but the one I want, but even then, executing:

 

print("figure3.png", "-dpng");


retrieves the last figure (figure 5) from somewhere (though I deleted it first), and ignores my meaning, that is, to print just figure 3. How do I do this?


Thanks,

Mark Lytle

Houston



_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave


Hi Mark,

print also accepts a 3 argument version where the first input is the handle of the figure you want to print.  So, you could do something like:

fig3_h = figure(3);
<other stuff>
print(fig3_h, "figure3.png", "-dpng");

Also, you could try setting the figure you want as the current figure, then printing:

figure(3);
print(gcf, "figure3.png", "-dpng");

where gcf is a function that returns the handle of the current figure.

As to why the figures exist after deleting them, you'll need to wait for someone more familiar with the insides of that part of octave to chime in.

I hope this helps.

James Sherman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]