11
11
Dict , Instance , Set , Bool , TraitError , Unicode
12
12
)
13
13
14
- #-----------------------------------------------------------------------------
15
- # Configurable for inline backend options
16
- #-----------------------------------------------------------------------------
17
14
15
+ # Configurable for inline backend options
18
16
def pil_available ():
19
17
"""Test if PIL/Pillow is available"""
20
18
out = False
21
19
try :
22
- from PIL import Image
20
+ from PIL import Image # noqa
23
21
out = True
24
- except :
22
+ except ImportError :
25
23
pass
26
24
return out
27
25
28
- # inherit from InlineBackendConfig for deprecation purposes
26
+
27
+ # Inherit from InlineBackendConfig for deprecation purposes
29
28
class InlineBackendConfig (SingletonConfigurable ):
30
29
pass
31
30
31
+
32
32
class InlineBackend (InlineBackendConfig ):
33
33
"""An object to store configuration of the inline backend."""
34
34
35
35
# The typical default figure size is too large for inline use,
36
36
# so we shrink the figure size to 6x4, and tweak fonts to
37
37
# make that fit.
38
- rc = Dict ({'figure.figsize' : (6.0 ,4.0 ),
39
- # play nicely with white background in the Qt and notebook frontend
40
- 'figure.facecolor' : (1 ,1 ,1 ,0 ),
41
- 'figure.edgecolor' : (1 ,1 ,1 ,0 ),
42
- # 12pt labels get cutoff on 6x4 logplots, so use 10pt.
43
- 'font.size' : 10 ,
44
- # 72 dpi matches SVG/qtconsole
45
- # this only affects PNG export, as SVG has no dpi setting
46
- 'figure.dpi' : 72 ,
47
- # 10pt still needs a little more room on the xlabel:
48
- 'figure.subplot.bottom' : .125
38
+ rc = Dict (
39
+ {
40
+ 'figure.figsize' : (6.0 , 4.0 ),
41
+ # play nicely with white background in the Qt and notebook frontend
42
+ 'figure.facecolor' : (1 , 1 , 1 , 0 ),
43
+ 'figure.edgecolor' : (1 , 1 , 1 , 0 ),
44
+ # 12pt labels get cutoff on 6x4 logplots, so use 10pt.
45
+ 'font.size' : 10 ,
46
+ # 72 dpi matches SVG/qtconsole
47
+ # this only affects PNG export, as SVG has no dpi setting
48
+ 'figure.dpi' : 72 ,
49
+ # 10pt still needs a little more room on the xlabel:
50
+ 'figure.subplot.bottom' : .125
49
51
},
50
52
help = """Subset of matplotlib rcParams that should be different for the
51
53
inline backend."""
52
54
).tag (config = True )
53
55
54
- figure_formats = Set ({'png' },
55
- help = """A set of figure formats to enable: 'png',
56
- 'retina', 'jpeg', 'svg', 'pdf'.""" ).tag (config = True )
56
+ figure_formats = Set (
57
+ {'png' },
58
+ help = """A set of figure formats to enable: 'png',
59
+ 'retina', 'jpeg', 'svg', 'pdf'.""" ).tag (config = True )
57
60
58
61
def _update_figure_formatters (self ):
59
62
if self .shell is not None :
@@ -73,15 +76,17 @@ def _figure_format_changed(self, name, old, new):
73
76
if new :
74
77
self .figure_formats = {new }
75
78
76
- print_figure_kwargs = Dict ({'bbox_inches' : 'tight' },
79
+ print_figure_kwargs = Dict (
80
+ {'bbox_inches' : 'tight' },
77
81
help = """Extra kwargs to be passed to fig.canvas.print_figure.
78
82
79
83
Logical examples include: bbox_inches, quality (for jpeg figures), etc.
80
84
"""
81
85
).tag (config = True )
82
86
_print_figure_kwargs_changed = _update_figure_formatters
83
87
84
- close_figures = Bool (True ,
88
+ close_figures = Bool (
89
+ True ,
85
90
help = """Close all figures at the end of each cell.
86
91
87
92
When True, ensures that each cell starts with no active figures, but it
0 commit comments