Practicing matplotlib, help with deprecation warning?


Hello Everyone!

Sorry if this isn’t the right place to post this type of question. If it’s not, I’ll gladly repost where it is acceptable.

I have been going through the matplotlib graphing different of plots course, and I wanted to practice on my own what I’ve learned.

I’ve come up with the following line graph:

#!/usr/bin/env python

# This line graph will show the sales of a number of comic book sales throughout the week

from matplotlib import pyplot as plt

comics = ["batman", "green lantern", "superman", "the flash", "wonder woman"]
sales = [700, 300, 450, 500, 550]
y_axis = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
y_axis_label = [ str(i) for i in y_axis ]


plt.plot(comics, sales, marker="s")

ax = plt.subplot()


plt.title("Comic book sales for the week")
plt.xlabel("Comic book")
plt.ylabel("Number of copies sold")

The graph plots as I would expect, but when running the script I receive the following warning:

MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
warnings.warn(message, mplDeprecation, stacklevel=1)

Could someone explain to me what I’m doing wrong to receive the deprecation warning, and how to fix it?