Saving Plots to Files
Any of the above plotting utilities can also be used for directly plotting
into eps
or png
files, or pdf
files if your gnuplot installation
allows. A final gnuplot.plotflush() command ensures that all output is
written to the file properly.
gnuplot.epsfigure('test.eps')
gnuplot.plot({'Sin Curve',torch.sin(torch.linspace(-5,5))})
gnuplot.xlabel('X')
gnuplot.ylabel('Y')
gnuplot.plotflush()
gnuplot.epsfigure(fname)
Creates a figure directly on the eps
file given with
fname
. This uses Gnuplot
terminal postscript eps enhanced color
.
gnuplot.pdffigure(fname)
Only available if your installation of gnuplot has been compiled
with pdf
support enabled.
Creates a figure directly on the pdf
file given with
fname
. This uses Gnuplot
terminal pdf enhanced color
,
or pdfcairo enhanced color
if available.
gnuplot.pngfigure(fname)
Creates a figure directly on the png
file given with
fname
. This uses Gnuplot
terminal png
, or pngcairo
if available.
gnuplot.svgfigure(fname)
Creates a figure directly on the svg
file given with fname
. This uses
Gnuplot
terminal svg
.
gnuplot.figprint(fname)
Prints the current figure to the given file with name fname
. Only png
or eps
files are supported by default. If your gnuplot installation
allows, pdf
files are also supported.
gnuplot.plotflush([n])
This command sends unset output
to underlying gnuplot. Useful for
flushing file based terminals.
gnuplot.close()
Closes open file handles. Prevents too many handles staying open if creating lots of plots.