Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve 'Javascript Error: IPython is not defined' while trying to plot interactively in a jupyter notebook

I would like to interactively plot in jupyter notebook. While using matplotlib.pyplot and trying to plot interactively through the code below, I get the error Javascript Error: IPython is not defined.

import matplotlib.pyplot as plt
%matplotlib notebook
plt.figure()
plt.plot(x, y)
plt.show()

This error has appeared after I updated the anaconda. I have searched in the internet for a solution, but could not solve the issue in a cleaner way.

like image 825
Somnath Jana Avatar asked Jul 27 '26 01:07

Somnath Jana


1 Answers

The notebook backend does not work in jupyter-lab (i.e. the problem is your line %matplotlib notebook which specifies the "notebook" backend for matplotlib)... You have to switch to ipympl for interactive plots for jupyter-lab or for jupyter notebook v7!

First install it, e.g.

pip install ipympl

then you can activate it with

%matplotlib widget
like image 59
raphael Avatar answered Jul 28 '26 16:07

raphael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!