X Tutup
Skip to content

Y-axis labels are impossible to align by baseline #1734

@jpaalasm

Description

@jpaalasm

As the example below shows, axis labels are not aligned by text baseline by default, which would be typographically correct.

import pylab

fig, ((ax1, ax2), (ax3, ax4)) = pylab.subplots(2, 2, figsize=(4,3.8))

for ax in ax1, ax2, ax3, ax4:
    ax.set_xticks([])
    ax.set_yticks([])

ax1.set_ylabel("aaaaaaaajaaaaaaa")
ax3.set_ylabel("aaaaaaaaaaaaaaaa")

ax3.set_xlabel("aaaaaaaajaaaaaaa")
ax4.set_xlabel("aaaaaaaaaaaaaaaa")

For the x-axis labels, alignment by baseline is possible to configure (code below), but it seems to be impossible to do for y-axis labels, because set_horizontalalignment("baseline") is not allowed.

ax3.xaxis.get_label().set_verticalalignment("baseline")
ax4.xaxis.get_label().set_verticalalignment("baseline")
ax3.xaxis.labelpad = 15
ax4.xaxis.labelpad = 15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup