1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import mpl_toolkits.axes_grid1.axes_size as Size from mpl_toolkits.axes_grid1 import Divider import matplotlib.pyplot as plt
fig1 = plt.figure(1, (5.5, 4))
rect = (0.1, 0.1, 0.8, 0.8) ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]
horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])] vert = [Size.AxesY(ax[0]), Size.Fixed(.5), Size.AxesY(ax[2])]
divider = Divider(fig1, rect, horiz, vert, aspect=False)
ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0)) ax[1].set_axes_locator(divider.new_locator(nx=2, ny=0)) ax[2].set_axes_locator(divider.new_locator(nx=0, ny=2)) ax[3].set_axes_locator(divider.new_locator(nx=2, ny=2))
ax[0].set_xlim(0, 2) ax[1].set_xlim(0, 1)
ax[0].set_ylim(0, 1) ax[2].set_ylim(0, 2)
divider.set_aspect(1.)
for ax1 in ax: ax1.tick_params(labelbottom=False, labelleft=False)
plt.show()
|