Skip to content

[Bug]: axes.get_tick_params() does not return labelbottom or labeltop #28772

Closed as not planned
GenieTim/matplotlib
#1

Description

@GenieTim

Bug summary

axes.get_tick_params() introduced in #23692 returns labelright and labelleft even for the x-axis, even though the keys should be called labelbottom or labeltop. This is confusing.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.tick_params(labelbottom=True, labeltop=True, labelright=True, labelleft=True)

tick_params = ax.get_xaxis().get_tick_params()

Actual outcome

tick_params = {
"labelright": True,
"labelleft": True,
# ..., no `labelbottom` or `labeltop`
}

Expected outcome

tick_params = {
"labelbottom": True,
"labeltop": True,
}

Additional information

The code path to this bug seems relatively clear, see here. Not sure though how to solve.

Operating system

Windows, MacOS

Matplotlib Version

3.9.1

Matplotlib Backend

No response

Python version

3.12.5

Jupyter version

No response

Installation

pip

Activity

  1. rcomer commented on Aug 31, 2024

    @rcomer
    Member

    Thanks for the clear report @GenieTim! I can reproduce this with our main development branch and with v3.7.0 (when this method was introduced). So it seems this has never worked correctly.

  2. rcomer commented on Aug 31, 2024

    @rcomer
    Member

    Marking as Good First Issue, because this should only require modifying the kwtrans dictionary here:

    keymap = {
    # tick_params key -> axis key
    'length': 'size',
    'direction': 'tickdir',
    'rotation': 'labelrotation',
    'left': 'tick1On',
    'bottom': 'tick1On',
    'right': 'tick2On',
    'top': 'tick2On',
    'labelleft': 'label1On',
    'labelbottom': 'label1On',
    'labelright': 'label2On',
    'labeltop': 'label2On',
    }
    if reverse:
    kwtrans = {
    oldkey: kw_.pop(newkey)
    for oldkey, newkey in keymap.items() if newkey in kw_
    }

    To check whether we're on the x- or y-axis, we can look at self.axis_name.

  3. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Aug 31, 2024
  4. github-actions commented on Aug 31, 2024

    @github-actions

    Good first issue - notes for new contributors

    This issue is suited to new contributors because it does not require understanding of the
    Matplotlib internals. To get started, please see our contributing
    guide
    .

    We do not assign issues. Check the Development section in the sidebar for linked pull
    requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please
    collaborate on the work by reviewing it rather than duplicating it in a competing PR.

    If something is unclear, please reach out on any of our communication
    channels
    .

  5. added a commit that references this issue on Aug 31, 2024
    8574adc
  6. MaozGelbart commented on Sep 12, 2024

    @MaozGelbart
    Contributor

    Hi, I think this is reported in #27416 .

  7. rcomer commented on Sep 12, 2024

    @rcomer
    Member

    Thanks for flagging that @MaozGelbart!

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