Skip to content

[Bug]: moving ticks to the top or left with tick_params makes get_ticks_position return "unknown" #21337

Closed
@anntzer

Description

@anntzer

Bug summary

See title.

Code for reproduction

from pylab import *

rcdefaults()
rcParams.update({
    "xtick.top": 1, "xtick.labeltop": 1, "xtick.bottom": 0, "xtick.labelbottom": 0,
    "ytick.right": 1, "ytick.labelright": 1, "ytick.left": 0, "ytick.labelleft": 0,})
ax = figure().add_subplot()
ax.figure.canvas.draw()
print(ax.xaxis.get_ticks_position(), ax.yaxis.get_ticks_position())

rcdefaults()
ax = figure().add_subplot()
ax.xaxis.tick_top()
ax.yaxis.tick_right()
ax.figure.canvas.draw()
print(ax.xaxis.get_ticks_position(), ax.yaxis.get_ticks_position())

rcdefaults()
ax = figure().add_subplot()
gca().tick_params(top=True, labeltop=True, bottom=False, labelbottom=False,
                  right=True, labelright=True, left=False, labelleft=False)
ax.figure.canvas.draw()
print(ax.xaxis.get_ticks_position(), ax.yaxis.get_ticks_position())

show()

Actual outcome

top right
top right
unknown unknown

Expected outcome

The last method for moving ticks should also make get_ticks_position() return "top"/"right".

Operating system

linux

Matplotlib Version

3.5.0.dev2254+g97ba9d41ef

Matplotlib Backend

any

Python version

3.9

Jupyter version

no

Other libraries

No response

Installation

No response

Conda channel

No response

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