summaryrefslogtreecommitdiffstats
path: root/contrib/python/matplotlib-inline/matplotlib_inline/config.py
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/matplotlib-inline/matplotlib_inline/config.py
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/matplotlib-inline/matplotlib_inline/config.py')
-rw-r--r--contrib/python/matplotlib-inline/matplotlib_inline/config.py214
1 files changed, 107 insertions, 107 deletions
diff --git a/contrib/python/matplotlib-inline/matplotlib_inline/config.py b/contrib/python/matplotlib-inline/matplotlib_inline/config.py
index c0f398069e0..608015aa772 100644
--- a/contrib/python/matplotlib-inline/matplotlib_inline/config.py
+++ b/contrib/python/matplotlib-inline/matplotlib_inline/config.py
@@ -1,107 +1,107 @@
-"""Configurable for configuring the IPython inline backend
-
-This module does not import anything from matplotlib.
-"""
-
-# Copyright (c) IPython Development Team.
-# Distributed under the terms of the BSD 3-Clause License.
-
-from traitlets.config.configurable import SingletonConfigurable
-from traitlets import (
- Dict, Instance, Set, Bool, TraitError, Unicode
-)
-
-
-# Configurable for inline backend options
-def pil_available():
- """Test if PIL/Pillow is available"""
- out = False
- try:
- from PIL import Image # noqa
- out = True
- except ImportError:
- pass
- return out
-
-
-# Inherit from InlineBackendConfig for deprecation purposes
-class InlineBackendConfig(SingletonConfigurable):
- pass
-
-
-class InlineBackend(InlineBackendConfig):
- """An object to store configuration of the inline backend."""
-
- # The typical default figure size is too large for inline use,
- # so we shrink the figure size to 6x4, and tweak fonts to
- # make that fit.
- rc = Dict(
- {
- 'figure.figsize': (6.0, 4.0),
- # play nicely with white background in the Qt and notebook frontend
- 'figure.facecolor': (1, 1, 1, 0),
- 'figure.edgecolor': (1, 1, 1, 0),
- # 12pt labels get cutoff on 6x4 logplots, so use 10pt.
- 'font.size': 10,
- # 72 dpi matches SVG/qtconsole
- # this only affects PNG export, as SVG has no dpi setting
- 'figure.dpi': 72,
- # 10pt still needs a little more room on the xlabel:
- 'figure.subplot.bottom': .125
- },
- help="""Subset of matplotlib rcParams that should be different for the
- inline backend."""
- ).tag(config=True)
-
- figure_formats = Set(
- {'png'},
- help="""A set of figure formats to enable: 'png',
- 'retina', 'jpeg', 'svg', 'pdf'.""").tag(config=True)
-
- def _update_figure_formatters(self):
- if self.shell is not None:
- from IPython.core.pylabtools import select_figure_formats
- select_figure_formats(self.shell, self.figure_formats, **self.print_figure_kwargs)
-
- def _figure_formats_changed(self, name, old, new):
- if 'jpg' in new or 'jpeg' in new:
- if not pil_available():
- raise TraitError("Requires PIL/Pillow for JPG figures")
- self._update_figure_formatters()
-
- figure_format = Unicode(help="""The figure format to enable (deprecated
- use `figure_formats` instead)""").tag(config=True)
-
- def _figure_format_changed(self, name, old, new):
- if new:
- self.figure_formats = {new}
-
- print_figure_kwargs = Dict(
- {'bbox_inches': 'tight'},
- help="""Extra kwargs to be passed to fig.canvas.print_figure.
-
- Logical examples include: bbox_inches, quality (for jpeg figures), etc.
- """
- ).tag(config=True)
- _print_figure_kwargs_changed = _update_figure_formatters
-
- close_figures = Bool(
- True,
- help="""Close all figures at the end of each cell.
-
- When True, ensures that each cell starts with no active figures, but it
- also means that one must keep track of references in order to edit or
- redraw figures in subsequent cells. This mode is ideal for the notebook,
- where residual plots from other cells might be surprising.
-
- When False, one must call figure() to create new figures. This means
- that gcf() and getfigs() can reference figures created in other cells,
- and the active figure can continue to be edited with pylab/pyplot
- methods that reference the current active figure. This mode facilitates
- iterative editing of figures, and behaves most consistently with
- other matplotlib backends, but figure barriers between cells must
- be explicit.
- """).tag(config=True)
-
- shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',
- allow_none=True)
+"""Configurable for configuring the IPython inline backend
+
+This module does not import anything from matplotlib.
+"""
+
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the BSD 3-Clause License.
+
+from traitlets.config.configurable import SingletonConfigurable
+from traitlets import (
+ Dict, Instance, Set, Bool, TraitError, Unicode
+)
+
+
+# Configurable for inline backend options
+def pil_available():
+ """Test if PIL/Pillow is available"""
+ out = False
+ try:
+ from PIL import Image # noqa
+ out = True
+ except ImportError:
+ pass
+ return out
+
+
+# Inherit from InlineBackendConfig for deprecation purposes
+class InlineBackendConfig(SingletonConfigurable):
+ pass
+
+
+class InlineBackend(InlineBackendConfig):
+ """An object to store configuration of the inline backend."""
+
+ # The typical default figure size is too large for inline use,
+ # so we shrink the figure size to 6x4, and tweak fonts to
+ # make that fit.
+ rc = Dict(
+ {
+ 'figure.figsize': (6.0, 4.0),
+ # play nicely with white background in the Qt and notebook frontend
+ 'figure.facecolor': (1, 1, 1, 0),
+ 'figure.edgecolor': (1, 1, 1, 0),
+ # 12pt labels get cutoff on 6x4 logplots, so use 10pt.
+ 'font.size': 10,
+ # 72 dpi matches SVG/qtconsole
+ # this only affects PNG export, as SVG has no dpi setting
+ 'figure.dpi': 72,
+ # 10pt still needs a little more room on the xlabel:
+ 'figure.subplot.bottom': .125
+ },
+ help="""Subset of matplotlib rcParams that should be different for the
+ inline backend."""
+ ).tag(config=True)
+
+ figure_formats = Set(
+ {'png'},
+ help="""A set of figure formats to enable: 'png',
+ 'retina', 'jpeg', 'svg', 'pdf'.""").tag(config=True)
+
+ def _update_figure_formatters(self):
+ if self.shell is not None:
+ from IPython.core.pylabtools import select_figure_formats
+ select_figure_formats(self.shell, self.figure_formats, **self.print_figure_kwargs)
+
+ def _figure_formats_changed(self, name, old, new):
+ if 'jpg' in new or 'jpeg' in new:
+ if not pil_available():
+ raise TraitError("Requires PIL/Pillow for JPG figures")
+ self._update_figure_formatters()
+
+ figure_format = Unicode(help="""The figure format to enable (deprecated
+ use `figure_formats` instead)""").tag(config=True)
+
+ def _figure_format_changed(self, name, old, new):
+ if new:
+ self.figure_formats = {new}
+
+ print_figure_kwargs = Dict(
+ {'bbox_inches': 'tight'},
+ help="""Extra kwargs to be passed to fig.canvas.print_figure.
+
+ Logical examples include: bbox_inches, quality (for jpeg figures), etc.
+ """
+ ).tag(config=True)
+ _print_figure_kwargs_changed = _update_figure_formatters
+
+ close_figures = Bool(
+ True,
+ help="""Close all figures at the end of each cell.
+
+ When True, ensures that each cell starts with no active figures, but it
+ also means that one must keep track of references in order to edit or
+ redraw figures in subsequent cells. This mode is ideal for the notebook,
+ where residual plots from other cells might be surprising.
+
+ When False, one must call figure() to create new figures. This means
+ that gcf() and getfigs() can reference figures created in other cells,
+ and the active figure can continue to be edited with pylab/pyplot
+ methods that reference the current active figure. This mode facilitates
+ iterative editing of figures, and behaves most consistently with
+ other matplotlib backends, but figure barriers between cells must
+ be explicit.
+ """).tag(config=True)
+
+ shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',
+ allow_none=True)