Skip to content

%matplotlib notebook magic no longer shows plots #18396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rsokl opened this issue Sep 2, 2020 · 6 comments
Closed

%matplotlib notebook magic no longer shows plots #18396

rsokl opened this issue Sep 2, 2020 · 6 comments

Comments

@rsokl
Copy link

rsokl commented Sep 2, 2020

Bug report

Bug summary

In Firefox (haven't tested other browsers), the %matplotlib notebook magic causes plots to not render.

Changing to %matplotlib inline will produce the plot

Code for reproduction

import matplotlib.pyplot as plt
%matplotlib notebook

fig, ax = plt.subplots()
ax.plot(range(10))

Actual outcome

image

Expected outcome

I expect a plot to be produced by the above code, instead of that weird charm that it displayed

Matplotlib version

  • Operating system: Ubuntu 18.04.4
  • Matplotlib version: 3.3.1
  • Matplotlib backend (print(matplotlib.get_backend())): nbAgg
  • Python version: 3.7.9
  • Jupyter version (if applicable):
  • Other libraries:
ipykernel                 5.3.4            py37h5ca1d4c_0
ipython                   7.18.1           py37h5ca1d4c_0
jupyter_client            6.1.6                      py_0
jupyter_core              4.6.3                    py37_0

Installed from conda, default channel.

@QuLogic
Copy link
Member

QuLogic commented Sep 2, 2020

What version of Firefox?

@ianhi
Copy link
Contributor

ianhi commented Sep 3, 2020

@rsokl have you tried flipping the order of the first two lines?
when I run your example I get a blank plot:
image

with this error in the console:

Exception inside the 'handler_close' callback: TypeError: this is undefined
    handle_close http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1 line 35520 > eval:727
    socket_on_message http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1 line 35520 > eval:542
    comm_websocket_adapter http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1 line 35520 > eval:692
    _callback http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1:37260
    handle_msg http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1:37268
    CommManager.prototype.comm_msg/this.comms[content.comm_id]< http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1:37198
 mpl.figure.prototype.handle_close@http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1 line 35520 > eval:727:5
socket_on_message@http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1 line 35520 > eval:542:25
comm_websocket_adapter/<@http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1 line 35520 > eval:692:12
Comm.prototype._callback@http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1:37260:24
Comm.prototype.handle_msg@http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1:37268:21
CommManager.prototype.comm_msg/this.comms[content.comm_id]<@http://localhost:8889/static/notebook/js/main.min.js?v=f71d682290e3b718d369f11ba1d1aef1:37198:42

also subsequent plots are embedded without interactivity
image

However if I swap the order of the first two lines

%matplotlib notebook
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(range(10))

then everything works as expected.

OS: PopOS 20.04 (basically ubuntu)
Browser: Firefox 78.0.1
matplotlib version: 3.3.1
python: '3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) \n[GCC 7.5.0]'

@ianhi
Copy link
Contributor

ianhi commented Sep 3, 2020

Also, I just checked and I see the same behavior on Chrome 83.0.4103.116 (Official Build) (64-bit)

@rsokl
Copy link
Author

rsokl commented Sep 3, 2020

Firefox Quantum 68.11.0esr (64-bit)

@ianhi unfortunately, neither of those behaviors manifest for me. These sorts of plots worked for my prior to an environment upgrade - I need to find time to do some version bisecting to find the culprit.

image

a-n-rose added a commit to a-n-rose/Python-Sound-Tool that referenced this issue Sep 21, 2020
@QuLogic
Copy link
Member

QuLogic commented Sep 23, 2020

Firefox Quantum 68.11.0esr (64-bit)

Ah, this is the same as #18481. See the workaround in #18481 (comment)

@jklymak
Copy link
Member

jklymak commented Sep 23, 2020

I don't think there is any reason for both issues to be open?

@jklymak jklymak closed this as completed Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants