Figure does not appear

Hi,
I am plotting in python but there is no figure appear on the screen. I have taken the code from
https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html

import matplotlib.pyplot as plt
import numpy as np

# Some example data to display
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('A single plot')

fig, axs = plt.subplots(2)
fig.suptitle('Vertically stacked subplots')
axs[0].plot(x, y)
axs[1].plot(x, -y)

fig, (ax1, ax2) = plt.subplots(2)
fig.suptitle('Vertically stacked subplots')
ax1.plot(x, y)
ax2.plot(x, -y)

Those examples are incomplete - they show how to prepare a plot.

You need a find “plt.show()” call to actually display the result.

Cheers,
Cameron Simpson cs@cskk.id.au

I meant “final”, not “find”. After preparing your plot, call plt.show()
to display it. - Cameron

1 Like

Yes now it works. I added “plt.show()” in the end.