1111 Dict , Instance , Set , Bool , TraitError , Unicode
1212)
1313
14- #-----------------------------------------------------------------------------
15- # Configurable for inline backend options
16- #-----------------------------------------------------------------------------
1714
15+ # Configurable for inline backend options
1816def pil_available ():
1917 """Test if PIL/Pillow is available"""
2018 out = False
2119 try :
22- from PIL import Image
20+ from PIL import Image # noqa
2321 out = True
24- except :
22+ except ImportError :
2523 pass
2624 return out
2725
28- # inherit from InlineBackendConfig for deprecation purposes
26+
27+ # Inherit from InlineBackendConfig for deprecation purposes
2928class InlineBackendConfig (SingletonConfigurable ):
3029 pass
3130
31+
3232class InlineBackend (InlineBackendConfig ):
3333 """An object to store configuration of the inline backend."""
3434
3535 # The typical default figure size is too large for inline use,
3636 # so we shrink the figure size to 6x4, and tweak fonts to
3737 # 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
4951 },
5052 help = """Subset of matplotlib rcParams that should be different for the
5153 inline backend."""
5254 ).tag (config = True )
5355
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 )
5760
5861 def _update_figure_formatters (self ):
5962 if self .shell is not None :
@@ -73,15 +76,17 @@ def _figure_format_changed(self, name, old, new):
7376 if new :
7477 self .figure_formats = {new }
7578
76- print_figure_kwargs = Dict ({'bbox_inches' : 'tight' },
79+ print_figure_kwargs = Dict (
80+ {'bbox_inches' : 'tight' },
7781 help = """Extra kwargs to be passed to fig.canvas.print_figure.
7882
7983 Logical examples include: bbox_inches, quality (for jpeg figures), etc.
8084 """
8185 ).tag (config = True )
8286 _print_figure_kwargs_changed = _update_figure_formatters
8387
84- close_figures = Bool (True ,
88+ close_figures = Bool (
89+ True ,
8590 help = """Close all figures at the end of each cell.
8691
8792 When True, ensures that each cell starts with no active figures, but it
0 commit comments