##// END OF EJS Templates
release 8.12.1
release 8.12.1

File last commit:

r28114:7d42b768
r28265:f4df70be
Show More
pylabtools.py
425 lines | 13.5 KiB | text/x-python | PythonLexer
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 # -*- coding: utf-8 -*-
MinRK
support `%matplotlib qt5`...
r18084 """Pylab (matplotlib) support utilities."""
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
MinRK
support `%matplotlib qt5`...
r18084 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
Grahame Bowland
Make PNG images in the Qt console work in Python 3.
r4773 from io import BytesIO
Min RK
print_figure return base64 str instead of bytes...
r26812 from binascii import b2a_base64
from functools import partial
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 import warnings
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280
MinRK
enable retina display of Image objects...
r10803 from IPython.core.display import _pngxy
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 from IPython.utils.decorators import flag_calls
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Fernando Perez
Add support for simultaneous interactive and inline matplotlib plots....
r2987 # If user specifies a GUI, that dictates the backend, otherwise we read the
# user's mpl default from the mpl rc structure
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 backends = {
"tk": "TkAgg",
"gtk": "GTKAgg",
"gtk3": "GTK3Agg",
Elliott Sales de Andrade
Add input hooks for GTK4.
r26726 "gtk4": "GTK4Agg",
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 "wx": "WXAgg",
"qt4": "Qt4Agg",
"qt5": "Qt5Agg",
Thomas A Caswell
ENH: add support for Qt6 input hooks...
r26683 "qt6": "QtAgg",
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 "qt": "Qt5Agg",
"osx": "MacOSX",
"nbagg": "nbAgg",
zhizheng1
Update pylabtools.py
r27852 "webagg": "WebAgg",
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 "notebook": "nbAgg",
"agg": "agg",
"svg": "svg",
"pdf": "pdf",
"ps": "ps",
"inline": "module://matplotlib_inline.backend_inline",
"ipympl": "module://ipympl.backend_nbagg",
"widget": "module://ipympl.backend_nbagg",
}
Fernando Perez
Add support for simultaneous interactive and inline matplotlib plots....
r2987
Fernando Perez
Fix support for raw GTK and WX matplotlib backends....
r3902 # We also need a reverse backends2guis mapping that will properly choose which
# GUI support to activate based on the desired matplotlib backend. For the
# most part it's just a reverse of the above dict, but we also need to add a
# few others that map to the same GUI manually:
backend2gui = dict(zip(backends.values(), backends.keys()))
# In the reverse mapping, there are a few extra valid matplotlib backends that
# map to the same GUI support
Matthias Bussonnier
reformat
r26736 backend2gui["GTK"] = backend2gui["GTKCairo"] = "gtk"
backend2gui["GTK3Cairo"] = "gtk3"
backend2gui["GTK4Cairo"] = "gtk4"
backend2gui["WX"] = "wx"
backend2gui["CocoaAgg"] = "osx"
Thomas A Caswell
FIX: make sure all of the Qt backends map to the qt event loop
r26831 # There needs to be a hysteresis here as the new QtAgg Matplotlib backend
# supports either Qt5 or Qt6 and the IPython qt event loop support Qt4, Qt5,
# and Qt6.
backend2gui["QtAgg"] = "qt"
backend2gui["Qt4Agg"] = "qt"
backend2gui["Qt5Agg"] = "qt"
Thomas Kluyver
Some mpl backends have no corresponding GUI...
r22877 # And some backends that don't need GUI integration
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 del backend2gui["nbAgg"]
del backend2gui["agg"]
del backend2gui["svg"]
del backend2gui["pdf"]
del backend2gui["ps"]
del backend2gui["module://matplotlib_inline.backend_inline"]
Thomas A Caswell
FIX: ipympl does not need event loop support
r26832 del backend2gui["module://ipympl.backend_nbagg"]
Fernando Perez
Fix support for raw GTK and WX matplotlib backends....
r3902
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 #-----------------------------------------------------------------------------
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280 # Matplotlib utilities
#-----------------------------------------------------------------------------
Brian Granger
Final work on display system....
r3288
def getfigs(*fig_nums):
"""Get a list of matplotlib figures by figure numbers.
If no arguments are given, all available figures are returned. If the
argument list contains references to invalid figures, a warning is printed
but the function continues pasting further figures.
Parameters
----------
figs : tuple
A tuple of ints giving the figure numbers of the figures to return.
"""
from matplotlib._pylab_helpers import Gcf
if not fig_nums:
fig_managers = Gcf.get_all_fig_managers()
return [fm.canvas.figure for fm in fig_managers]
else:
figs = []
for num in fig_nums:
f = Gcf.figs.get(num)
if f is None:
Thomas Kluyver
Clean up converted code....
r13386 print('Warning: figure %s not available.' % num)
Brian Granger
Renaming the special methods of the formatters....
r3878 else:
figs.append(f.canvas.figure)
Brian Granger
Final work on display system....
r3288 return figs
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280 def figsize(sizex, sizey):
"""Set the default figure size to be [sizex, sizey].
This is just an easy to remember, convenience wrapper that sets::
matplotlib.rcParams['figure.figsize'] = [sizex, sizey]
"""
import matplotlib
matplotlib.rcParams['figure.figsize'] = [sizex, sizey]
Min RK
print_figure return base64 str instead of bytes...
r26812 def print_figure(fig, fmt="png", bbox_inches="tight", base64=False, **kwargs):
MinRK
print_figure returns unicode for svg
r16048 """Print a figure to an image, and return the resulting file data
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
print_figure returns unicode for svg
r16048 Returned data will be bytes unless ``fmt='svg'``,
in which case it will be unicode.
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
specify default bbox_inches in print_figure explicitly...
r15394 Any keyword args are passed to fig.canvas.print_figure,
MinRK
add InlineBackend.print_figure_kwargs...
r15342 such as ``quality`` or ``bbox_inches``.
Min RK
print_figure return base64 str instead of bytes...
r26812
If `base64` is True, return base64-encoded str instead of raw bytes
for binary-encoded image formats
Matthias Bussonnier
A few modification to fix docs passing....
r27136 .. versionadded:: 7.29
Min RK
print_figure return base64 str instead of bytes...
r26812 base64 argument
Daniel B. Vasquez
Forgot to import TraitError....
r14773 """
Fernando Perez
Do not generate output for empty figures in Qt console....
r3731 # When there's an empty figure, we shouldn't return anything, otherwise we
# get big blank areas in the qt console.
Fernando Perez
Display figures with no axes but lines, which are also valid.
r5732 if not fig.axes and not fig.lines:
Fernando Perez
Do not generate output for empty figures in Qt console....
r3731 return
Hassan Kibirige
Remove access to 'savefig.dpi', use figure.dpi...
r22789 dpi = fig.dpi
MinRK
enable retina matplotlib figures
r10802 if fmt == 'retina':
dpi = dpi * 2
MinRK
enable retina display of Image objects...
r10803 fmt = 'png'
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
add InlineBackend.print_figure_kwargs...
r15342 # build keyword args
Srinivas Reddy Thatiparthy
remove dict() function call and replace it with dict literal - {}
r23231 kw = {
"format":fmt,
"facecolor":fig.get_facecolor(),
"edgecolor":fig.get_edgecolor(),
"dpi":dpi,
"bbox_inches":bbox_inches,
}
MinRK
add InlineBackend.print_figure_kwargs...
r15342 # **kwargs get higher priority
kw.update(kwargs)
Thomas A Caswell
MNT: ensure we can show un-pickled figures...
r25419
MinRK
add InlineBackend.print_figure_kwargs...
r15342 bytes_io = BytesIO()
Thomas A Caswell
MNT: ensure we can show un-pickled figures...
r25419 if fig.canvas is None:
from matplotlib.backend_bases import FigureCanvasBase
FigureCanvasBase(fig)
MinRK
add InlineBackend.print_figure_kwargs...
r15342 fig.canvas.print_figure(bytes_io, **kw)
MinRK
print_figure returns unicode for svg
r16048 data = bytes_io.getvalue()
if fmt == 'svg':
data = data.decode('utf-8')
Min RK
print_figure return base64 str instead of bytes...
r26812 elif base64:
Alexey Zaytsev
Don't emit a trailng newline in base64-encoded data like 'image/png'
r28114 data = b2a_base64(data, newline=False).decode("ascii")
MinRK
print_figure returns unicode for svg
r16048 return data
Thomas A Caswell
MNT: ensure we can show un-pickled figures...
r25419
Min RK
print_figure return base64 str instead of bytes...
r26812 def retina_figure(fig, base64=False, **kwargs):
"""format a figure as a pixel-doubled (retina) PNG
If `base64` is True, return base64-encoded str instead of raw bytes
for binary-encoded image formats
Matthias Bussonnier
A few modification to fix docs passing....
r27136 .. versionadded:: 7.29
Min RK
print_figure return base64 str instead of bytes...
r26812 base64 argument
"""
pngdata = print_figure(fig, fmt="retina", base64=False, **kwargs)
Christopher Roach
Added a fix for issue #8871
r21813 # Make sure that retina_figure acts just like print_figure and returns
# None when the figure is empty.
if pngdata is None:
return
MinRK
enable retina display of Image objects...
r10803 w, h = _pngxy(pngdata)
Srinivas Reddy Thatiparthy
remove dict() function call and replace it with dict literal - {}
r23231 metadata = {"width": w//2, "height":h//2}
Min RK
print_figure return base64 str instead of bytes...
r26812 if base64:
Alexey Zaytsev
Don't emit a trailng newline in base64-encoded data like 'image/png'
r28114 pngdata = b2a_base64(pngdata, newline=False).decode("ascii")
MinRK
enable retina matplotlib figures
r10802 return pngdata, metadata
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280
Min RK
print_figure return base64 str instead of bytes...
r26812
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280 # We need a little factory function here to create the closure where
# safe_execfile can live.
def mpl_runner(safe_execfile):
"""Factory to return a matplotlib-enabled runner for %run.
Parameters
----------
safe_execfile : function
Matthias Bussonnier
some docstring reformatting and fixing
r27288 This must be a function with the same interface as the
:meth:`safe_execfile` method of IPython.
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280
Returns
-------
A function suitable for use as the ``runner`` argument of the %run magic
function.
"""
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280 def mpl_execfile(fname,*where,**kw):
"""matplotlib-aware wrapper around safe_execfile.
Its interface is identical to that of the :func:`execfile` builtin.
This is ultimately a call to execfile(), but wrapped in safeties to
properly handle interactive rendering."""
import matplotlib
Thomas A Caswell
MNT: remove unneeded pylab imports...
r22944 import matplotlib.pyplot as plt
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280
#print '*** Matplotlib runner ***' # dbg
# turn off rendering until end of script
is_interactive = matplotlib.rcParams['interactive']
matplotlib.interactive(False)
safe_execfile(fname,*where,**kw)
matplotlib.interactive(is_interactive)
# make rendering call now, if the user tried to do it
Thomas A Caswell
MNT: remove unneeded pylab imports...
r22944 if plt.draw_if_interactive.called:
plt.draw()
plt.draw_if_interactive.called = False
Thomas A Caswell
MNT: add hook for mpl > 1.5...
r22945 # re-draw everything that is stale
try:
da = plt.draw_all
except AttributeError:
pass
else:
da()
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280
return mpl_execfile
Min RK
reshow nbagg figures on display...
r21962 def _reshow_nbagg_figure(fig):
"""reshow an nbagg figure"""
try:
reshow = fig.canvas.manager.reshow
Ram Rachum
Fix exception causes all over the codebase
r25833 except AttributeError as e:
raise NotImplementedError() from e
Min RK
reshow nbagg figures on display...
r21962 else:
reshow()
MinRK
add InlineBackend.print_figure_kwargs...
r15342 def select_figure_formats(shell, formats, **kwargs):
Brian E. Granger
Adding support for multiple figure formats in InlineBackend.
r15122 """Select figure formats for the inline backend.
MinRK
add InlineBackendConfig...
r3973
Brian E. Granger
Adding support for multiple figure formats in InlineBackend.
r15122 Parameters
Matthias Bussonnier
some docstring reformatting and fixing
r27288 ----------
Brian E. Granger
Adding support for multiple figure formats in InlineBackend.
r15122 shell : InteractiveShell
Brian E. Granger
Docstring improvement.
r15125 The main IPython instance.
MinRK
add InlineBackend.print_figure_kwargs...
r15342 formats : str or set
Brian E. Granger
Adding support for multiple figure formats in InlineBackend.
r15122 One or a set of figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'.
MinRK
add InlineBackend.print_figure_kwargs...
r15342 **kwargs : any
Extra keyword arguments to be passed to fig.canvas.print_figure.
MinRK
add InlineBackendConfig...
r3973 """
Min RK
reshow nbagg figures on display...
r21962 import matplotlib
MinRK
add InlineBackendConfig...
r3973 from matplotlib.figure import Figure
svg_formatter = shell.display_formatter.formatters['image/svg+xml']
png_formatter = shell.display_formatter.formatters['image/png']
Daniel B. Vasquez
Add JPEG as an image format for inline backend if PIL/pillow is available.
r14770 jpg_formatter = shell.display_formatter.formatters['image/jpeg']
Brian E. Granger
Adding support for multiple figure formats in InlineBackend.
r15122 pdf_formatter = shell.display_formatter.formatters['application/pdf']
MinRK
add InlineBackendConfig...
r3973
Srinivas Reddy Thatiparthy
convert string_types to str
r23037 if isinstance(formats, str):
Brian E. Granger
Adding support for multiple figure formats in InlineBackend.
r15122 formats = {formats}
MinRK
add InlineBackend.print_figure_kwargs...
r15342 # cast in case of list / tuple
formats = set(formats)
Daniel B. Vasquez
Move testing for PIL[low] in the _figure_format_changed(...) function instead...
r14772
MinRK
add InlineBackend.print_figure_kwargs...
r15342 [ f.pop(Figure, None) for f in shell.display_formatter.formatters.values() ]
Jens Hedegaard Nielsen
add reshow to ipympl backend
r23018 mplbackend = matplotlib.get_backend().lower()
if mplbackend == 'nbagg' or mplbackend == 'module://ipympl.backend_nbagg':
Min RK
reshow nbagg figures on display...
r21962 formatter = shell.display_formatter.ipython_display_formatter
formatter.for_type(Figure, _reshow_nbagg_figure)
MinRK
add InlineBackend.print_figure_kwargs...
r15342 supported = {'png', 'png2x', 'retina', 'jpg', 'jpeg', 'svg', 'pdf'}
bad = formats.difference(supported)
if bad:
MinRK
generate supported formats in ValueError
r15397 bs = "%s" % ','.join([repr(f) for f in bad])
gs = "%s" % ','.join([repr(f) for f in supported])
raise ValueError("supported formats are: %s not %s" % (gs, bs))
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
Min RK
print_figure return base64 str instead of bytes...
r26812 if "png" in formats:
png_formatter.for_type(
Figure, partial(print_figure, fmt="png", base64=True, **kwargs)
)
if "retina" in formats or "png2x" in formats:
png_formatter.for_type(Figure, partial(retina_figure, base64=True, **kwargs))
if "jpg" in formats or "jpeg" in formats:
jpg_formatter.for_type(
Figure, partial(print_figure, fmt="jpg", base64=True, **kwargs)
)
if "svg" in formats:
svg_formatter.for_type(Figure, partial(print_figure, fmt="svg", **kwargs))
if "pdf" in formats:
pdf_formatter.for_type(
Figure, partial(print_figure, fmt="pdf", base64=True, **kwargs)
)
MinRK
add InlineBackendConfig...
r3973
Brian Granger
Lots of work on the display system, focused on pylab stuff....
r3280 #-----------------------------------------------------------------------------
# Code for initializing matplotlib and importing pylab
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 #-----------------------------------------------------------------------------
Ryan May
Implement bare %pylab switching back to appropriate GUI.
r7965 def find_gui_and_backend(gui=None, gui_select=None):
Brian Granger
Initial GUI support in kernel.
r2868 """Given a gui string return the gui and mpl backend.
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Parameters
----------
Brian Granger
Initial GUI support in kernel.
r2868 gui : str
Matteo
Updated docstring for agg backend and gui...
r22833 Can be one of ('tk','gtk','wx','qt','qt4','inline','agg').
Ryan May
Implement bare %pylab switching back to appropriate GUI.
r7965 gui_select : str
Can be one of ('tk','gtk','wx','qt','qt4','inline').
This is any gui already selected by the shell.
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Returns
-------
Brian Granger
Initial GUI support in kernel.
r2868 A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg',
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 'WXAgg','Qt4Agg','module://matplotlib_inline.backend_inline','agg').
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 """
import matplotlib
MinRK
quiet error messages instead of tracebacks in %pylab/%gui...
r5162 if gui and gui != 'auto':
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 # select backend based on requested gui
Fernando Perez
Add support for simultaneous interactive and inline matplotlib plots....
r2987 backend = backends[gui]
Matteo
Added '%matplotlib agg' option....
r22830 if gui == 'agg':
gui = None
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 else:
Fernando Perez
Switch correctly to the user's default matplotlib backend after inline....
r12593 # We need to read the backend from the original data structure, *not*
# from mpl.rcParams, since a prior invocation of %matplotlib may have
# overwritten that.
Fernando Perez
Add comment as per PR discussion, indicating MPL 1.1 is now required.
r12639 # WARNING: this assumes matplotlib 1.1 or newer!!
Fernando Perez
Switch correctly to the user's default matplotlib backend after inline....
r12593 backend = matplotlib.rcParamsOrig['backend']
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 # In this case, we need to find what the appropriate gui selection call
# should be for IPython, so we can activate inputhook accordingly
Fernando Perez
Fix support for raw GTK and WX matplotlib backends....
r3902 gui = backend2gui.get(backend, None)
Ryan May
Implement bare %pylab switching back to appropriate GUI.
r7965
# If we have already had a gui active, we need it and inline are the
# ones allowed.
if gui_select and gui != gui_select:
gui = gui_select
backend = backends[gui]
Brian Granger
Initial GUI support in kernel.
r2868 return gui, backend
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Brian Granger
Initial GUI support in kernel.
r2868
def activate_matplotlib(backend):
"""Activate the given backend and set interactive to True."""
import matplotlib
matplotlib.interactive(True)
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
Ryan May
Make use of matplotlib's switch_backend()...
r7939 # Matplotlib had a bug where even switch_backend could not force
# the rcParam to update. This needs to be set *before* the module
# magic of switch_backend().
matplotlib.rcParams['backend'] = backend
Ben Lewis
Change matplotlib.pyplot import syntax (for circular import bug)
r25195 # Due to circular imports, pyplot may be only partially initialised
# when this function runs.
# So avoid needing matplotlib attribute-lookup to access pyplot.
from matplotlib import pyplot as plt
Ryan May
Make use of matplotlib's switch_backend()...
r7939
Ben Lewis
Change matplotlib.pyplot import syntax (for circular import bug)
r25195 plt.switch_backend(backend)
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Thomas A Caswell
MNT: remove unneeded pylab imports...
r22944 plt.show._needmain = False
Brian Granger
GUI support for wx, qt and tk.
r2872 # We need to detect at runtime whether show() is called by the user.
# For this, we wrap it into a decorator which adds a 'called' flag.
Thomas A Caswell
MNT: remove unneeded pylab imports...
r22944 plt.draw_if_interactive = flag_calls(plt.draw_if_interactive)
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Fernando Perez
Refactor gui/pylab integration to eliminate code duplication....
r5469
def import_pylab(user_ns, import_all=True):
MinRK
adjust `import_pylab`...
r11323 """Populate the namespace with pylab-related values.
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
adjust `import_pylab`...
r11323 Imports matplotlib, pylab, numpy, and everything from pylab and numpy.
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
adjust `import_pylab`...
r11323 Also imports a few names from IPython (figsize, display, getfigs)
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
adjust `import_pylab`...
r11323 """
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
# Import numpy as np/pyplot as plt are conventions we're trying to
# somewhat standardize on. Making them available to users by default
Fernando Perez
Fix name pollution of interactive namespace in pylab mode....
r3195 # will greatly help this.
s = ("import numpy\n"
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 "import matplotlib\n"
"from matplotlib import pylab, mlab, pyplot\n"
"np = numpy\n"
"plt = pyplot\n"
Fernando Perez
Fix name pollution of interactive namespace in pylab mode....
r3195 )
Thomas Kluyver
Fix exec statements for Py 3...
r13350 exec(s, user_ns)
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
add `%matplotlib` and `shell.enable_matplotlib`...
r11328 if import_all:
s = ("from matplotlib.pylab import *\n"
"from numpy import *\n")
Thomas Kluyver
Fix exec statements for Py 3...
r13350 exec(s, user_ns)
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
MinRK
adjust `import_pylab`...
r11323 # IPython symbols to add
user_ns['figsize'] = figsize
Matthias Bussonnier
Do not import from IPython.core.display and warn users.
r25632 from IPython.display import display
MinRK
adjust `import_pylab`...
r11323 # Add display and getfigs to the user's namespace
user_ns['display'] = display
user_ns['getfigs'] = getfigs
Fernando Perez
Fix critical bug with pylab support inadvertently introduced in #648....
r5468
Fernando Perez
Refactor gui/pylab integration to eliminate code duplication....
r5469
MinRK
add `%matplotlib` and `shell.enable_matplotlib`...
r11328 def configure_inline_support(shell, backend):
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 """
Matthias Bussonnier
A few modification to fix docs passing....
r27136 .. deprecated:: 7.23
Matthias Bussonnier
better doc
r26474
use `matplotlib_inline.backend_inline.configure_inline_support()`
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464
Configure an IPython shell object for matplotlib use.
Fernando Perez
Refactor gui/pylab integration to eliminate code duplication....
r5469
Parameters
----------
shell : InteractiveShell instance
Fernando Perez
Fix inline backend logic and avoid tests if mpl not available.
r5474 backend : matplotlib backend
Fernando Perez
Refactor gui/pylab integration to eliminate code duplication....
r5469 """
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 warnings.warn(
Matthias Bussonnier
better doc
r26474 "`configure_inline_support` is deprecated since IPython 7.23, directly "
"use `matplotlib_inline.backend_inline.configure_inline_support()`",
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 DeprecationWarning,
stacklevel=2,
)
Fernando Perez
Refactor gui/pylab integration to eliminate code duplication....
r5469
Paul Ivanov
fix linting missed while darker was broken
r26524 from matplotlib_inline.backend_inline import (
configure_inline_support as configure_inline_support_orig,
)
Fernando Perez
Fix inline backend logic and avoid tests if mpl not available.
r5474
martinRenou
Use matplotlib-inline instead of ipykernel.pylab
r26464 configure_inline_support_orig(shell, backend)