Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changes in IPython kernel
=========================

4.4
---

4.4.0
*****

`4.4.0 on GitHub <https://github.com/ipython/ipykernel/milestones/4.4>`__

- Use `MPLBACKEND`_ environment variable to tell matplotlib >= 1.5 use use the inline backend by default.
This is only done if MPLBACKEND is not already set and no backend has been explicitly loaded,
so setting ``MPLBACKEND=Qt4Agg`` or calling ``%matplotlib notebook`` or ``matplotlib.use('Agg')``
will take precedence.

.. _MPLBACKEND: http://matplotlib.org/devel/coding_guide.html?highlight=mplbackend#developing-a-new-backend

4.3
---

Expand Down
7 changes: 7 additions & 0 deletions ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,13 @@ def init_kernel(self):
def init_gui_pylab(self):
"""Enable GUI event loop integration, taking pylab into account."""

# Register inline backend as default
# this is higher priority than matplotlibrc,
# but lower priority than anything else (mpl.use() for instance).
# This only affects matplotlib >= 1.5
if not os.environ.get('MPLBACKEND'):
os.environ['MPLBACKEND'] = 'module://ipykernel.pylab.backend_inline'

# Provide a wrapper for :meth:`InteractiveShellApp.init_gui_pylab`
# to ensure that any exception is printed straight to stderr.
# Normally _showtraceback associates the reply with an execution,
Expand Down
11 changes: 11 additions & 0 deletions ipykernel/pylab/backend_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,14 @@ def flush_figures():
# figurecanvas. This is set here to a Agg canvas
# See https://github.com/matplotlib/matplotlib/pull/1125
FigureCanvas = FigureCanvasAgg

def _enable_matplotlib_integration():
"""Enable extra IPython matplotlib integration when we are loaded as the matplotlib backend."""
from matplotlib import get_backend
from IPython.core.pylabtools import configure_inline_support
ip = get_ipython()
backend = get_backend()
if ip and backend == 'module://%s' % __name__:
configure_inline_support(ip, backend)

_enable_matplotlib_integration()