The use of
plt.subplot() is really supposed to be a method to create a new axis subplot so if you’re using it, make sure to do so at the start to ensure any additional commands plot to the correct axis (it now has a deprecation warning for this behaviour too).
plt.legend would technically work if you’re using just a single axis. It does require a sequence of labels though, e.g.
plt.legend(["data1", "data2"]), ideally at the same length as what you are creating a legend for (for basic options the rest is automated anyway).
Something to consider: using figure/axis references and their methods...
Peronsally I’d encourage you to get used to using the axis reference though “
ax” or whatever name you provided it. For more complex plots, relying on standard pyplot functions can result in a bit of a headache. Even MATLAB which matplotlib generally emulates seemed to wind up using objects for this.
It’s up to you to use this style if you wish and you can get away with the pyplot wrapper functions for a lot of things (though references to invidual figures and axes is still very important so keep them either way) but here’s how the plotting for your given example might look-
fig, ax = plt.subplots(1, 1)
ax.set_title('Sales of drink at 2 store locations by types')