0

Why doesn't this code show the graph when i first press shift & enter? I have to press shift enter twice before the graph shows up. After i pressed shift enter once, the output shows

<matplotlib.figure.Figure at 0x2560f0e8630>

This is my code:

import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt

objects = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')
y_pos = np.arange(len(objects))
performance = [10,8,6,4,2,1]

plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('Usage')
plt.title('Programming language usage')
plt.show()
Mr. T
  • 8,325
  • 9
  • 23
  • 44
1234321
  • 31
  • 6
  • 1
    Shift Enter -- are you using ipython or something? Because as a general script this displays the graph without needing any interaction. – jedwards Jun 16 '18 at 05:45
  • @jedwards im using python 3 jupyter notebook – 1234321 Jun 16 '18 at 05:46
  • 2
    Check out [this related](https://stackoverflow.com/questions/19410042/how-to-make-ipython-notebook-matplotlib-plot-inline). – jedwards Jun 16 '18 at 05:48
  • 1
    @jedwards, I'd say duplicate rather than related. Also, I can't reproduce the issue on my version of Jupyter notebook. – Zev Jun 16 '18 at 06:00
  • 1
    Possible duplicate of [How to make IPython notebook matplotlib plot inline](https://stackoverflow.com/questions/19410042/how-to-make-ipython-notebook-matplotlib-plot-inline) – Zev Jun 16 '18 at 06:00

0 Answers0