publiplots.savefig

publiplots.savefig(filepath, dpi=None, format=None, bbox_inches='tight', transparent=True, facecolor=None, edgecolor=None, pad_inches=0.1, **kwargs)[source]

Save figure with publication-ready defaults.

This function wraps matplotlib’s savefig with sensible defaults for publication-quality output. It automatically creates parent directories if they don’t exist.

Parameters:
  • filepath (str) – Output file path. The file extension determines the format if format parameter is not specified.

  • dpi (int, optional) – Dots per inch for rasterized output. If None, uses DEFAULT_DPI (300). Ignored for vector formats (PDF, SVG, EPS).

  • format (str, optional) – File format (e.g., ‘png’, ‘pdf’, ‘svg’, ‘eps’). If None, inferred from filepath extension.

  • bbox_inches (str, default='tight') – Bounding box setting. ‘tight’ removes extra whitespace.

  • transparent (bool, default=False) – If True, make background transparent (PNG, PDF, SVG).

  • facecolor (str, optional) – Figure face color. If None, uses current figure facecolor.

  • edgecolor (str, optional) – Figure edge color. If None, uses current figure edgecolor.

  • pad_inches (float, default=0.1) – Padding around the figure when bbox_inches=’tight’.

  • **kwargs (Any) – Additional keyword arguments passed to matplotlib.pyplot.savefig().

Examples

Save a figure with default settings: >>> import publiplots as pp >>> fig, ax = pp.scatterplot(data, x=’x’, y=’y’) >>> pp.savefig(‘output.png’)

Save with higher DPI: >>> pp.savefig(‘output.png’, dpi=600)

Save as PDF (vector format): >>> pp.savefig(‘output.pdf’)

Save with transparency: >>> pp.savefig(‘output.png’, transparent=True)

Notes

  • For publications, use DPI >= 300 for rasterized formats (PNG, JPEG)

  • For presentations, DPI = 150 is usually sufficient

  • For vector formats (PDF, SVG, EPS), DPI is ignored

  • PNG format is recommended for web and presentations

  • PDF format is recommended for publications (vector graphics)