Skip to content

[ENH]: Make rotation_mode="xtick" the default for ticks #29926

Open

Description

@timhoffm

#28968 introduced new rotation modes "xtick"/"ytick". We've employed them to all our examples, as this rotation setting is superior compared to fiddling with horizontal/verticalalignment. It's "how tick rotation should be".

Proposed solution

Make these the default rotation modes for tick labels.

Technically, this is a breaking change, but I argue it's the better default and the breakage is minor:

  • If users did not specify alignment, it's changed from "centered" alignment to the "pointing to tick" aligment.
  • If users have cared to do the "pointing" to tick alignment manually (which is what we were teaching in examples before), their plot will stay the same.
  • If users have chosen other alignment, they'll need to adapt.

This is a tradeoff between making a reasonable default so that in the future rotated ticks are "just right" and people don't have to do rotation_mode="xtick" explicitly all the time and breaking explicit alignment compatibility for a few rare edge cases.

Activity

  1. kc9323 commented on May 1, 2025

    @kc9323
    Contributor

    Hi @timhoffm , may I work on this issue?

  2. timhoffm commented on May 2, 2025

    @timhoffm
    MemberAuthor

    @kyracho you are welcome! Two slight caveats:

    • As written, this is a tradeoff. I believe it's worth it, but there may be other core devs with a stronger sense of backward compatibility.
    • I'm still thinking about whether we can make the transition more smooth, e.g. warn in the case of the third bullet point above.
  3. timhoffm commented on Jun 24, 2025

    @timhoffm
    MemberAuthor

    Actually, it's slightly more complicated.

    plt.plot([3, 2, 1])
    plt.xticks(['foo', 'bar', 'baz'], ha='left')
    

    would ignore the ha if the rotation mode is set to xtick by default.

    What we could do: For rotation_mode="xtick" only take the computed horizontalalignment if rotation!=0. This means for unrotated text, a user-set horizontalalignment value is kept.

  4. timhoffm commented on Mar 2, 2026

    @timhoffm
    MemberAuthor

    Likely the "clean" approach would be to track whether the alignment was set by the user. If so, respect that, otherwise let rotation_mode adjust the alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions