Skip to content

Commit f2ceb78

Browse files
committed
Make inline the default matplotlib backend
uses MPLBACKEND env (matplotlib > 1.5). Trigger extra IPython inline setup when inline backend is loaded. We can't call the simpler `ip.enable_matplotlib()` here because this will be triggered during pyplot import, and enable_matplotlib() imports pyplot which isn't ready yet.
1 parent f8b959e commit f2ceb78

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

backend_inline.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,14 @@ def flush_figures():
143143
# figurecanvas. This is set here to a Agg canvas
144144
# See https://github.com/matplotlib/matplotlib/pull/1125
145145
FigureCanvas = FigureCanvasAgg
146+
147+
def _enable_matplotlib_integration():
148+
"""Enable extra IPython matplotlib integration when we are loaded as the matplotlib backend."""
149+
from matplotlib import get_backend
150+
from IPython.core.pylabtools import configure_inline_support
151+
ip = get_ipython()
152+
backend = get_backend()
153+
if ip and backend == 'module://%s' % __name__:
154+
configure_inline_support(ip, backend)
155+
156+
_enable_matplotlib_integration()

0 commit comments

Comments
 (0)