savefig#

class savefig(filename=None, comments=None, fig=None, **kwargs)[source]#

Wrapper for Matplotlib’s pl.savefig() function which automatically stores HPVsim metadata in the figure.

By default, saves (git) information from both the HPVsim version and the calling function. Additional comments can be added to the saved file as well. These can be retrieved via hpv.get_png_metadata() (or sciris.sc_plotting.loadmetadata()). Metadata can also be stored for PDF, but cannot be automatically retrieved.

Parameters:
  • filename (str/list) – name of the file to save to (default, timestamp); can also be a list of names

  • comments (str/dict) – additional metadata to save to the figure

  • fig (fig/list) – figure to save (by default, current one); can also be a list of figures

  • kwargs (dict) – passed to fig.savefig()

Example:

hpv.Sim().run().plot()
hpv.savefig()