Home > Software engineering >  Matplotlib - The graph does not show in Pycharm
Matplotlib - The graph does not show in Pycharm

Time:10-27

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.

CodePudding user response:

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
  • Related