I start with the usual imports and go to start an interactive plotting session:
# for viewing figures interactively
%matplotlib notebook
# To start plotting in matplotlib
import IPython
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("whitegrid")
# Other data libraries
import numpy as np
import pandas as pd
# 3 dimensional plotting
from mpl_toolkits import mplot3d
# enable three-dimensional axes
fig = plt.figure()
ax = plt.axes(projection='3d')
this results in the error:
Javascript Error: IPython is not defined
Then I read here to test some other things. I install IPython Widgets:
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
Now putting %matplotlib widgets
instead of %matplotlib notebook
at the beginning of the codes displays the interactive figure.
In another approach, I can go and install ipympl and enable that extension:
pip install ipympl
jupyter nbextension enable --py --sys-prefix ipympl
After that useing %matplotlib ipympl
instead of %matplotlib notebook
at the first line shows the figure interactively.
But, the error for notebook magic command still persists. The thing is, this gets around the error and makes the code work but it does not solve the problem. I still have no clue why JavaScript cannot recognize IPyhton.
Any ideas for really solving the issue?