1

When I run the code below my iPython Notebooks starts working on it (I see black dot in the top right corner), but it never stops. I cannot stop it either by pressing button with the black square. I opened my other notebook and it shows the histogram without any problem. What can be the reason?

Thank you.

import matplotlib.pyplot as plt
from numpy.random import normal
gaussian_numbers = normal(size=1000)
plt.hist(gaussian_numbers)
plt.title("Gaussian Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()

UPDATE: Created a new notebook. Passed all the code from the previous notebook (including code that gets the data from the internet). Can any other code affect working and displaying the histogram? There is not other code working when I run histogram.

Sergey
  • 67
  • 5
  • It's working for me! – sascha Jul 26 '15 at 17:44
  • for me as well, what version of ipython, matplotlib do you have ? – Yann Jul 26 '15 at 17:50
  • possible duplicate: http://stackoverflow.com/questions/28733490/ipython-notebook-stops-evaluating-cells-after-plt-show/28737233 – cel Jul 26 '15 at 17:53
  • Cel, thank you. I missed that posted and his suggestions worked. Should I delete this one? – Sergey Jul 26 '15 at 18:01
  • I suggested a duplicate note which you can accept. Of course you are free to delete your post, but there's no need for that. Often duplicates are not easy to find - so there's no need to be embarrassed either. – cel Jul 26 '15 at 18:21

1 Answers1

0

yo need to use%matplotlib inline

%matplotlib inline
import matplotlib.pyplot as plt
from numpy.random import normal
gaussian_numbers = normal(size=1000)
plt.hist(gaussian_numbers)
plt.title("Gaussian Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()

see this other thread to automatically do this on the IPython configuration Automatically run %matplotlib inline in iPython Notebook

efirvida
  • 4,592
  • 3
  • 42
  • 68