Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cleanup API for setting ticks #15005

Copy link
Copy link
Closed
Closed
Copy link
@timhoffm

Description

@timhoffm
Issue body actions

Inspired by #14980 (comment).

Current APIs:

pyplot.xticks(ticks=None, labels=None, **kwargs)

Axes.set_xticks(self, ticks, minor=False)
Axes.set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs)

Notes:

  • The Axes methods are just thin wrappers around the Axis methods.
  • The kwargs are Text properties.

Issue

The Axes API feels a bit odd. AFAICS set_xticklabels does not make much sense without set_xticks before; otherwise how do I know that the labels will be at the correct places and that I have the right number of labels for the ticks.

Proposal

  1. Extend the API of set_xticks to be
    Axes.set_xticks(self, ticks, labels=None, minor=False, **kwargs)
    
    maybe even with ticks=None to be compatible with the pyplot API - though I don't know if one needs the ability to set ticks without positions.
  2. Soft-deprecate set_xticklabels. It's too widely used to be deprecated, but we shouldn't have two equal ways here.
  3. Optionally add the minor kwarg to pyplot.xticks; it's not strictly necessary because pyplot may have less functionality than the OOP interface; but it doesn't hurt either.

The proposed signature would be an API-change because the minor argument might have been passed positionally. Thus, we should start with _make_keyword_only on that parameter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.