Skip to content

Commit 6673aa6

Browse files
authored
Docstring of set_matplotlib_formats (#51)
#44
2 parents 011561d + 20f78c4 commit 6673aa6

File tree

3 files changed

+254
-3
lines changed

3 files changed

+254
-3
lines changed

matplotlib_inline/backend_inline.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,32 @@ def set_matplotlib_formats(*formats, **kwargs):
275275
276276
For example, this enables PNG and JPEG output with a JPEG quality of 90%::
277277
278-
In [1]: set_matplotlib_formats('png', 'jpeg', quality=90)
278+
In [1]: set_matplotlib_formats('png', 'jpeg',
279+
pil_kwargs={'quality': 90})
280+
281+
To set this in your notebook by `%config` magic::
282+
283+
In [1]: %config InlineBackend.figure_formats = {'png', 'jpeg'}
284+
%config InlineBackend.print_figure_kwargs = \\
285+
{'pil_kwargs': {'quality' : 90}}
279286
280287
To set this in your config files use the following::
281288
282289
c.InlineBackend.figure_formats = {'png', 'jpeg'}
283-
c.InlineBackend.print_figure_kwargs.update({'quality' : 90})
290+
c.InlineBackend.print_figure_kwargs.update({
291+
'pil_kwargs': {'quality' : 90}
292+
})
284293
285294
Parameters
286295
----------
287296
*formats : strs
288297
One or more figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'.
289298
**kwargs
290299
Keyword args will be relayed to ``figure.canvas.print_figure``.
300+
301+
In addition, see the docstrings of `plt.savefig()`,
302+
`matplotlib.figure.Figure.savefig()`, `PIL.Image.Image.save()` and
303+
:ref:`Pillow Image file formats <handbook/image-file-formats>`.
291304
"""
292305
# build kwargs, starting with InlineBackend config
293306
cfg = InlineBackend.instance()

matplotlib_inline/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def _figure_format_changed(self, name, old, new):
7979
{"bbox_inches": "tight"},
8080
help="""Extra kwargs to be passed to fig.canvas.print_figure.
8181
82-
Logical examples include: bbox_inches, quality (for jpeg figures), etc.
82+
Logical examples include: bbox_inches, pil_kwargs, etc. In addition,
83+
see the docstrings of `set_matplotlib_formats`.
8384
""",
8485
).tag(config=True)
8586
_print_figure_kwargs_changed = _update_figure_formatters

0 commit comments

Comments
 (0)