From 546225e1bb60336c8fe6aa421c96173a16f6342c 2014-02-06 22:11:13 From: Brian E. Granger Date: 2014-02-06 22:11:13 Subject: [PATCH] Adding top level IPython.display.select_matplotlib_formats. --- diff --git a/IPython/core/display.py b/IPython/core/display.py index f853f73..8d15057 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -717,3 +717,20 @@ def clear_output(wait=False): io.stdout.flush() print('\033[2K\r', file=io.stderr, end='') io.stderr.flush() + + +def select_matplotlib_formats(formats, quality=90): + """Select figure formats for the inline backend. + + Parameters + ========== + formats : list + One or a set of figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'. + quality : int + A percentage for the quality of JPEG figures. + """ + from IPython.core.interactiveshell import InteractiveShell + from IPython.core.pylabtools import select_figure_formats + shell = InteractiveShell.instance() + select_figure_formats(shell, formats, quality=90) + diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index f232404..37f7900 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -166,7 +166,7 @@ def mpl_runner(safe_execfile): return mpl_execfile -def select_figure_format(shell, formats, quality=90): +def select_figure_formats(shell, formats, quality=90): """Select figure formats for the inline backend. Parameters @@ -352,5 +352,5 @@ def configure_inline_support(shell, backend): del shell._saved_rcParams # Setup the default figure format - select_figure_format(shell, cfg.figure_formats, cfg.quality) + select_figure_formats(shell, cfg.figure_formats, cfg.quality) diff --git a/IPython/kernel/zmq/pylab/config.py b/IPython/kernel/zmq/pylab/config.py index d3d06ab..680155b 100644 --- a/IPython/kernel/zmq/pylab/config.py +++ b/IPython/kernel/zmq/pylab/config.py @@ -70,14 +70,14 @@ class InlineBackend(InlineBackendConfig): 'retina', 'jpeg', 'svg', 'pdf'.""") def _figure_formats_changed(self, name, old, new): - from IPython.core.pylabtools import select_figure_format + from IPython.core.pylabtools import select_figure_formats if 'jpg' in new or 'jpeg' in new: if not pil_available(): raise TraitError("Requires PIL/Pillow for JPG figures") if self.shell is None: return else: - select_figure_format(self.shell, new) + select_figure_formats(self.shell, new) figure_format = Unicode(config=True, help="""The figure format to enable (deprecated use `figure_formats` instead)""")