8000 [Bug]: prune parameter of MaxNLocator has no effect · Issue #27274 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: prune parameter of MaxNLocator has no effect #27274
Closed
@ainar

Description

@ainar

Bug summary

The MaxNLocator with the prune parameter does not work as documented.
I read:

prune: {'lower', 'upper', 'both', None}, default: None

Remove edge ticks -- useful for stacked or ganged plots where the upper tick of one axes overlaps with the lower tick of the axes above it, primarily when rcParams["axes.autolimit_mode"] (default: 'data') is 'round_numbers'. If prune=='lower', the smallest tick will be removed. If prune == 'upper', the largest tick will be removed. If prune == 'both', the largest and smallest ticks will be removed. If prune is None, no ticks will be removed.

However, no tick is removed when I set prune to "lower", "upper" or "both".

Code for reproduction

from matplotlib import pyplot as plt
from matplotlib import ticker as mtick
fig, ax = plt.subplots()
ax.plot(range(4), range(4))
ax.xaxis.set_major_locator(mtick.MaxNLocator(4, prune="both"))

Actual outcome

image

Expected outcome

MaxNLocator_prune_expected

Additional information

No response

Operating system

Ubuntu

Matplotlib Version

3.8.0

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.12.0

Jupyter version

4.0.7

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0