savefigs#

savefigs(figs=None, filetype=None, filename=None, folder=None, savefigargs=None, aslist=False, verbose=False, **kwargs)[source]#

Save the requested plots to disk.

Parameters:
  • figs (list) – the figure objects to save

  • filetype (str) – the file type; can be ‘fig’, ‘singlepdf’ (default), or anything supported by savefig()

  • filename (str) – the file to save to (only uses path if multiple files)

  • folder (str) – the folder to save the file(s) in

  • savefigargs (dict) – arguments passed to savefig()

  • aslist (bool) – whether or not return a list even for a single file

  • varbose (bool) – whether to print progress

Examples:

import pylab as pl
import sciris as sc
fig1 = pl.figure(); pl.plot(pl.rand(10))
fig2 = pl.figure(); pl.plot(pl.rand(10))
sc.savefigs([fig1, fig2]) # Save everything to one PDF file
sc.savefigs(fig2, 'png', filename='myfig.png', savefigargs={'dpi':200})
sc.savefigs([fig1, fig2], filepath='/home/me', filetype='svg')
sc.savefigs(fig1, position=[0.3,0.3,0.5,0.5])

If saved as ‘fig’, then can load and display the plot using sc.loadfig().

Version: 2018aug26