python - populating 3x3 subplots with broken axis

Viewed 31

I'd like to have broken axes for all the 3x3 subplots. How can this be done? All the examples I found were for max. 2 plots.

My code would look something like this where I try to add a new axes and set the limits but it doesn't work:

from mpl_toolkits.axes_grid1 import make_axes_locatable
import matplotlib.pyplot as plt

fig,  ax= plt.subplots(nrows=3, ncols=3, sharex=True, sharey=True, figsize=(17, 12), facecolor='white')

xx = [*range(13)]
j=0

for month in target_months:
    for pl in range(3):
        for op in range(3):

            divider = make_axes_locatable(ax[pl, op])
            ax2 = divider.new_vertical(size="100%", pad=0.1)
            fig.add_axes(ax2)

            ax[pl,op].set_title("some title")

            ax[pl, op].set_ylim(50,65)
            ax[pl, op].spines['top'].set_visible(False)
            ax[pl, op].plot(xx[j], np.mean(some_data[op, pl, :, :])(, "-x",color="red")
            ax2.set_ylim(0,25)
            ax2.spines['bottom'].set_visible(False)
            ax2.plot(xx[j], some_data[op, pl, :, :], "-x", color="blue")



plt.show()

0 Answers
Related