Reputation: 4878
I just started to use Jupiter Notebook
to learn Python
. while I am trying out matplotlib
with this basic code:
import numpy as np
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
The kernel just keep running and nothing happen. How to resolve this? Is there an dependency issue? My newly installed matplotlib
is 1.5.1, python
is 3.5.2, numpy
is 1.11. Running on MacBook Pro 10.11(El Capitan).
Upvotes: 0
Views: 1357
Reputation: 13510
It sometimes takes time until the kernel starts.
Check that the code is color-highlighted. If it is, it means that the kernel is running. Evaluate the cell again. You will notice a *
beside that cell, meaning it's running.
And one more thing: Sometimes the plot is displayed but its window hides behind the notebook... Access it from the task bar
Upvotes: 0
Reputation: 4581
To Visualize the plots created by the matplotlib in Jupiter Notebook or ipython notebook you have add one extra line at the beginning.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
If your matplotlib version is above 1.4, and you are using IPython 3.x you have to use the below code.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook
Upvotes: 2
Reputation: 1511
It likely showed you a Matplotlib popup, with the IP(y) logo. To show it inline you have to use some IPython magic. Run this in a cell somewhere:
%matplotlib inline
After you close the popup it will finish the statement in your kernel
Upvotes: 0