I can not wrap my head around axes parameter, what it contains and how to use it for making subplots.
Would really appreciate if someone could explain what is going on in the following example
fig, axes = plt.subplots(nrows=3, ncols=4, figsize=(15, 10))
for idx, feature in enumerate(df.columns[:-1]):
df.plot(feature, "cnt", subplots=True, kind="scatter", ax=axes[idx / 4, idx % 4])
Here is the data (UCI Bike sharing dataset): Here is the output of the code snippet (a pairwise comparison of features and the end results):
To be more specific, here are the parts that I do understand (at least I think I do)
- plt.subplots returns a tuple containing a figure and axes object(s) (link)
- enumerate() returns a tuple containing index of a feature and its name(link)
- df.plot uses column names to put data on subplots within fig
Here is what I do not understand
- What does axes object contain? Again, based on documentation and this answer I do realize that axes contains "Axis, Tick, Line2D, Text, Polygon, etc." but
- what do we address using axes[x,y] ?
- why in this example author decided to use [idx / 4, idx % 4] as values?