'Plotting matplotlib figure through a class doesn't work

I created a class "Plot" for matplotlib plot objects. Running the following code neither shows error nor outputs anything. Any help is much appreciated.

import matplotlib.pyplot as plt

class Plot:
    def __init__(self):
        self.fig = plt.figure()
        self.ax = self.fig.add_subplot()
    def create_plot_background(self):
        self.ax.set_xlabel('X')
        self.ax.set_ylabel('Y')

x, y = [range(10), range(10)]

p = Plot()

p.create_plot_background()
p.ax.plot(x, y)
p.fig.show()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source