atompy.savefig#
- atompy.savefig(fname=None, ftype=None, fig=None, **savefig_kwargs)[source]#
Save a
matplotlib.figure.Figureto a file.Wraps
matplotlib.pyplot.savefig().- Parameters:
- fig
matplotlib.figure.Figure, optional If
None, use last active figure.- fname
str, optional File name (and path).
If
None, uses the filename of the programs entry point.If a file name without a file-type extension is provided, uses rcParams[“savefig.format”] unless ftype is provided.
If fname ends in
/or\, it is assumed as a directory in which the output will be saved using the file name of the programs entry point.If
*is in fname, replace it with the file name of the programs entry point.- ftype
stror Sequence[str], optional The file type(s).
If provided, the appropriate extension is appended to fname and the file is saved as that file type.
If a sequence is provided, saves one file for each provided type.
If nothing is provided, infers the file type from fname.
- fig
- Other Parameters:
- **savefig_kwargs
Keyword arguments of
matplotlib.pyplot.savefig().
See also
Examples
Assume a script named
my_plot.pywith the contentsmy_plot.py#import atompy as ap plt.plot(some_data) ap.savefig() ap.savefig(ftype="pdf") ap.savefig("output/") ap.savefig("output/*_extra") ap.savefig("a_plot") ap.savefig("a_plot", ftype=("pdf", "png")) ap.savefig("a_plot.pdf", ftype=("pdf", "png"))
Executing
my_plot.pywill save:my_plot.png(assuming plt.rcParams[“savefig.format”] = “png”)my_plot.pdfoutput/my_plot.pngoutput/my_plot_extra.pnga_plot.pdfa_plot.pdfanda_plot.pnga_plot.pdf.pdfanda_plot.pdf.png