Alinhando rótulos #

Alinhando xlabel e ylabel usando Figure.align_xlabelse Figure.align_ylabels

Figure.align_labelsenvolve essas duas funções.

Observe que o xlabel "XLabel1 1" normalmente estaria muito mais próximo do eixo x e "YLabel1 0" estaria muito mais próximo do eixo y de seus respectivos eixos.

demonstração de alinhamento de rótulos
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.gridspec as gridspec

fig = plt.figure(tight_layout=True)
gs = gridspec.GridSpec(2, 2)

ax = fig.add_subplot(gs[0, :])
ax.plot(np.arange(0, 1e6, 1000))
ax.set_ylabel('YLabel0')
ax.set_xlabel('XLabel0')

for i in range(2):
    ax = fig.add_subplot(gs[1, i])
    ax.plot(np.arange(1., 0., -0.1) * 2000., np.arange(1., 0., -0.1))
    ax.set_ylabel('YLabel1 %d' % i)
    ax.set_xlabel('XLabel1 %d' % i)
    if i == 0:
        ax.tick_params(axis='x', rotation=55)
fig.align_labels()  # same as fig.align_xlabels(); fig.align_ylabels()

plt.show()

Galeria gerada por Sphinx-Gallery