8000 Axes range with set_xticks with categoricals · Issue #12994 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Axes range with set_xticks with categoricals #12994
Closed
@timhoffm

Description

@timhoffm

Bug report

Bug summary

The axes range is not correctly extended when using set_xticks with not-yet-present categoricals.

Semi-related to #12993.

Code for reproduction

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
ax1.bar(['a', 'b'], [1 , 2])
ax2.bar(['a', 'b'], [1 , 2])
ax3.bar(['a', 'b'], [1 , 2])
ax4.bar(['a', 'b'], [1 , 2])
ax1.set_xticks(['b'])
ax2.set_xticks(['b', 'c'])
ax3.set_xticks(['c'])
ax4.set_xticks(['b', 'c', 'd'])

image

  • ax1 is correct.
  • ax3 is missing the 'c' label completely.
  • For ax2 and ax4, the x-range should be 0.5 larger so that the label is not at the edge.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0