Matplotlib – The graph does not show in Pycharm

I just started learning matplotlib. The code I used is here below:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [2,4,6]

plt.plot([x, y])


The graph doesn’t show up. It just gets stuck. Is there a way to fix it?

I am a beginner matplotlibber, so I’m just following a tutorial, but this doesn’t work for me. I just simply want the graph to show up.

>Solution :

You missing the:

plt.show()

So your code become:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [2,4,6]

plt.plot([x, y])
plt.show()

Or, if you are using a Jupiter Notebook:

%matplotlib inline

Leave a Reply