Show More
@@ -95,7 +95,9 b' def figsize(sizex, sizey):' | |||||
95 |
|
95 | |||
96 |
|
96 | |||
97 | def print_figure(fig, fmt='png', quality=90): |
|
97 | def print_figure(fig, fmt='png', quality=90): | |
98 |
"""Convert a figure to svg, png or jpg for inline display. |
|
98 | """Convert a figure to svg, png or jpg for inline display. | |
|
99 | Quality is only relevant for jpg. | |||
|
100 | """ | |||
99 | from matplotlib import rcParams |
|
101 | from matplotlib import rcParams | |
100 | # When there's an empty figure, we shouldn't return anything, otherwise we |
|
102 | # When there's an empty figure, we shouldn't return anything, otherwise we | |
101 | # get big blank areas in the qt console. |
|
103 | # get big blank areas in the qt console. |
@@ -14,7 +14,7 b' This module does not import anything from matplotlib.' | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 |
|
15 | |||
16 | from IPython.config.configurable import SingletonConfigurable |
|
16 | from IPython.config.configurable import SingletonConfigurable | |
17 | from IPython.utils.traitlets import Dict, Instance, CaselessStrEnum, Bool, Int |
|
17 | from IPython.utils.traitlets import Dict, Instance, CaselessStrEnum, Bool, Int, TraitError | |
18 | from IPython.utils.warn import warn |
|
18 | from IPython.utils.warn import warn | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
@@ -66,8 +66,8 b' class InlineBackend(InlineBackendConfig):' | |||||
66 |
|
66 | |||
67 | figure_format = CaselessStrEnum(['svg', 'png', 'retina', 'jpg'], |
|
67 | figure_format = CaselessStrEnum(['svg', 'png', 'retina', 'jpg'], | |
68 | default_value='png', config=True, |
|
68 | default_value='png', config=True, | |
69 |
help="""The image format for figures with the inline |
|
69 | help="""The image format for figures with the inline | |
70 | JPEG requires the PIL/Pillow library.""") |
|
70 | backend. JPEG requires the PIL/Pillow library.""") | |
71 |
|
71 | |||
72 | def _figure_format_changed(self, name, old, new): |
|
72 | def _figure_format_changed(self, name, old, new): | |
73 | from IPython.core.pylabtools import select_figure_format |
|
73 | from IPython.core.pylabtools import select_figure_format | |
@@ -80,11 +80,11 b' class InlineBackend(InlineBackendConfig):' | |||||
80 | select_figure_format(self.shell, new) |
|
80 | select_figure_format(self.shell, new) | |
81 |
|
81 | |||
82 | quality = Int(default_value=90, config=True, |
|
82 | quality = Int(default_value=90, config=True, | |
83 | help="Quality of compression [0-100], currently for lossy JPEG only.") |
|
83 | help="Quality of compression [10-100], currently for lossy JPEG only.") | |
84 |
|
84 | |||
85 | def _quality_changed(self, name, old, new): |
|
85 | def _quality_changed(self, name, old, new): | |
86 | if new < 0 or new > 100: |
|
86 | if new < 10 or new > 100: | |
87 | raise TraitError("figure quality must be in [0-100] range.") |
|
87 | raise TraitError("figure JPEG quality must be in [10-100] range.") | |
88 |
|
88 | |||
89 | close_figures = Bool(True, config=True, |
|
89 | close_figures = Bool(True, config=True, | |
90 | help="""Close all figures at the end of each cell. |
|
90 | help="""Close all figures at the end of each cell. |
General Comments 0
You need to be logged in to leave comments.
Login now