MCPcopy Create free account
hub / github.com/ipython/ipython / set_matplotlib_formats

Function set_matplotlib_formats

IPython/core/display.py:1473–1501  ·  view source on GitHub ↗

Select figure formats for the inline backend. Optionally pass quality for JPEG. For example, this enables PNG and JPEG output with a JPEG quality of 90%:: In [1]: set_matplotlib_formats('png', 'jpeg', quality=90) To set this in your config files use the following:: c.Inli

(*formats, **kwargs)

Source from the content-addressed store, hash-verified

1471
1472@skip_doctest
1473def set_matplotlib_formats(*formats, **kwargs):
1474 """Select figure formats for the inline backend. Optionally pass quality for JPEG.
1475
1476 For example, this enables PNG and JPEG output with a JPEG quality of 90%::
1477
1478 In [1]: set_matplotlib_formats('png', 'jpeg', quality=90)
1479
1480 To set this in your config files use the following::
1481
1482 c.InlineBackend.figure_formats = {'png', 'jpeg'}
1483 c.InlineBackend.print_figure_kwargs.update({'quality' : 90})
1484
1485 Parameters
1486 ----------
1487 *formats : strs
1488 One or more figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'.
1489 **kwargs :
1490 Keyword args will be relayed to ``figure.canvas.print_figure``.
1491 """
1492 from IPython.core.interactiveshell import InteractiveShell
1493 from IPython.core.pylabtools import select_figure_formats
1494 # build kwargs, starting with InlineBackend config
1495 kw = {}
1496 from ipykernel.pylab.config import InlineBackend
1497 cfg = InlineBackend.instance()
1498 kw.update(cfg.print_figure_kwargs)
1499 kw.update(**kwargs)
1500 shell = InteractiveShell.instance()
1501 select_figure_formats(shell, formats, **kw)
1502
1503@skip_doctest
1504def set_matplotlib_close(close=True):

Callers

nothing calls this directly

Calls 2

select_figure_formatsFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected