![]() ![]() See how now all 3 ax refer the the same place (so the axe ot uses is the same axe produced by the subplot added to the figure), and in each loop a new axe is properly added and new bar graph from a dataframe column is drawn in there, rather than drawing in the same old single axe.Ĭonclusion is do not touch OOP api until you require it and know what objects you want to manipulate. To see how it works properly with plt.figure(), cols = Judging by the above warning in source code, it seems we should never create figures in OOP way but use plt.figure(). I don’t know how to attach axes created from add_subplot of an Object-oriented created figure to the figure manager. I tried to provide the ax into ax= parameter of ot but the axes were showing empty space with no graphs so maybe this is the wrong way to do it. shows what’s in the figure as of current loop. They are also overlapping in this screenshot but because the x-axis scale is so different the 1st loop loop is in the tiny bottom left corner of 2nd loop plot. Note how the subsequent plots go into the same axe because they have same address 0x7f0012037C18 in photo (this will change every run, just compare same or different to understand the point), that’s why your plots overlap. We can see the subplot axe was created properly, but it is different from the axe pandas was using, and the figure manager did not register that this new ax was created, so was plotting in the axe returned by plt.gca(). ![]() plt.gca() the current axis called by pandas ot when no axes is provided to the ax= parameter so pandas automatically calls plt.gca() (You can know it’s that by tracing through def plot_series -> def _gca starting from - pandas 0.24.2 documentation).which is the axe (currently in focus) used by pandas ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |