Show More
@@ -717,3 +717,20 b' def clear_output(wait=False):' | |||||
717 | io.stdout.flush() |
|
717 | io.stdout.flush() | |
718 | print('\033[2K\r', file=io.stderr, end='') |
|
718 | print('\033[2K\r', file=io.stderr, end='') | |
719 | io.stderr.flush() |
|
719 | io.stderr.flush() | |
|
720 | ||||
|
721 | ||||
|
722 | def select_matplotlib_formats(formats, quality=90): | |||
|
723 | """Select figure formats for the inline backend. | |||
|
724 | ||||
|
725 | Parameters | |||
|
726 | ========== | |||
|
727 | formats : list | |||
|
728 | One or a set of figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'. | |||
|
729 | quality : int | |||
|
730 | A percentage for the quality of JPEG figures. | |||
|
731 | """ | |||
|
732 | from IPython.core.interactiveshell import InteractiveShell | |||
|
733 | from IPython.core.pylabtools import select_figure_formats | |||
|
734 | shell = InteractiveShell.instance() | |||
|
735 | select_figure_formats(shell, formats, quality=90) | |||
|
736 |
@@ -166,7 +166,7 b' def mpl_runner(safe_execfile):' | |||||
166 | return mpl_execfile |
|
166 | return mpl_execfile | |
167 |
|
167 | |||
168 |
|
168 | |||
169 | def select_figure_format(shell, formats, quality=90): |
|
169 | def select_figure_formats(shell, formats, quality=90): | |
170 | """Select figure formats for the inline backend. |
|
170 | """Select figure formats for the inline backend. | |
171 |
|
171 | |||
172 | Parameters |
|
172 | Parameters | |
@@ -352,5 +352,5 b' def configure_inline_support(shell, backend):' | |||||
352 | del shell._saved_rcParams |
|
352 | del shell._saved_rcParams | |
353 |
|
353 | |||
354 | # Setup the default figure format |
|
354 | # Setup the default figure format | |
355 | select_figure_format(shell, cfg.figure_formats, cfg.quality) |
|
355 | select_figure_formats(shell, cfg.figure_formats, cfg.quality) | |
356 |
|
356 |
@@ -70,14 +70,14 b' class InlineBackend(InlineBackendConfig):' | |||||
70 | 'retina', 'jpeg', 'svg', 'pdf'.""") |
|
70 | 'retina', 'jpeg', 'svg', 'pdf'.""") | |
71 |
|
71 | |||
72 | def _figure_formats_changed(self, name, old, new): |
|
72 | def _figure_formats_changed(self, name, old, new): | |
73 | from IPython.core.pylabtools import select_figure_format |
|
73 | from IPython.core.pylabtools import select_figure_formats | |
74 | if 'jpg' in new or 'jpeg' in new: |
|
74 | if 'jpg' in new or 'jpeg' in new: | |
75 | if not pil_available(): |
|
75 | if not pil_available(): | |
76 | raise TraitError("Requires PIL/Pillow for JPG figures") |
|
76 | raise TraitError("Requires PIL/Pillow for JPG figures") | |
77 | if self.shell is None: |
|
77 | if self.shell is None: | |
78 | return |
|
78 | return | |
79 | else: |
|
79 | else: | |
80 | select_figure_format(self.shell, new) |
|
80 | select_figure_formats(self.shell, new) | |
81 |
|
81 | |||
82 | figure_format = Unicode(config=True, help="""The figure format to enable (deprecated |
|
82 | figure_format = Unicode(config=True, help="""The figure format to enable (deprecated | |
83 | use `figure_formats` instead)""") |
|
83 | use `figure_formats` instead)""") |
General Comments 0
You need to be logged in to leave comments.
Login now