Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: axvspan no longer participating in limit calculations #28383

Closed
@bmcfee

Description

@bmcfee

Bug summary

Since upgrading to matplotlib 3.9, axvspan plots no longer seem to be included in limit calculations. I suspect this is due to the change from Polygon to Rectangle, but it does seem to have some unintended consequences.

Code for reproduction

In [2]: fig, ax = plt.subplots()

In [3]: ax.axvspan(0.5, 1.0)
Out[3]: <matplotlib.patches.Rectangle object at 0x7080118bbf80>

In [4]: ax.set(title='Matplotlib 3.9.0')
Out[4]: [Text(0.5, 1.0, 'Matplotlib 3.9.0')]

Actual outcome

image

Note that the axis limits are still centered at 0, and the vspan is out of frame.

Expected outcome

image

In 3.8.4, the limits would adapt to the location of the generated artist.

Additional information

This is causing us some problems in mir_eval, where we have high-level plot constructors that are built entirely from axvspans for showing time-series segmentation labels.

Operating system

all

Matplotlib Version

3.9.0

Matplotlib Backend

tkagg, but shouldn't matter

Python version

3.12

Jupyter version

n/a

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions