Skip to content

Commit cc39dc5

Browse files
committed
Ipython REPL backend bugfix
1 parent a2b8914 commit cc39dc5

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ ProPlot v0.3.0 (2020-01-##)
6060
with a default ``.proplotrc`` file, change the auto-generated user ``.proplotrc``
6161
(:pr:`50`).
6262

63+
ProPlot v0.3.1 (2019-12-XX)
64+
===========================
65+
.. rubric:: Bug fixes
66+
67+
- Repair issue with latest versions of matplotlib where ``%matplotlib inline``
68+
fails *silently* so the backend is not instantiated.
69+
6370
ProPlot v0.3.0 (2019-12-15)
6471
===========================
6572
.. rubric:: Deprecated

proplot/rctools.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -911,20 +911,21 @@ def ipython_matplotlib(backend=None, fmt=None):
911911
return
912912

913913
# For notebooks
914+
# WARNING: Latest version of matplotlib does not raise error when
915+
# https://stackoverflow.com/a/22424821/4970632
914916
rc._init = False
915-
ibackend = ('inline' if backend == 'auto' else backend)
917+
ibackend = backend
918+
if backend == 'auto':
919+
if 'IPKernelApp' in getattr(get_ipython(), 'config', ''):
920+
ibackend = 'inline'
921+
else:
922+
ibackend = 'qt'
916923
try:
917924
ipython.magic('matplotlib ' + ibackend)
918925
rc.reset()
919-
# For terminals (UnknownBackend is subclass of KeyError)
920926
except KeyError:
921927
if backend != 'auto':
922928
_warn_proplot(f'{"%matplotlib " + backend!r} failed.')
923-
try:
924-
ipython.magic('matplotlib qt') # use any available Qt backend
925-
rc.reset()
926-
except KeyError:
927-
pass # should be impossible, matplotlib needs Qt!
928929

929930
# Configure inline backend no matter what type of session this is
930931
# Should be silently ignored for terminal ipython sessions
@@ -1037,4 +1038,4 @@ def use_font(font=None):
10371038
ipython_matplotlib()
10381039
ipython_autoreload()
10391040
ipython_autosave()
1040-
use_font()
1041+
# use_font()

0 commit comments

Comments
 (0)