How to share axes after adding subplots via add_subplot? How to share axes after adding subplots via add_subplot? pandas pandas

How to share axes after adding subplots via add_subplot?


The question how to produce shared subplots in matplotlib:

What may be more interesting here, is that you could also directly use pandas to create the plot in a single line:

import pandas as pdimport matplotlib.pyplot as pltdf = pd.DataFrame({'A': [0.3, 0.2, 0.5, 0.2], 'B': [0.1, 0.0, 0.3, 0.1], 'C': [0.2, 0.5, 0.0, 0.7], 'D': [0.6, 0.3, 0.4, 0.6]}, index=list('abcd'))df.plot(kind="bar", subplots=True, layout=(2,2), sharey=True, sharex=True)plt.show()

enter image description here