Skip to content

[Bug]: Incorrect X-axis scaling with date values #28341

@pm13

Description

@pm13

Bug summary

In matplotlib 3.9.0, when plotting dates on the X-axis, calling axhspan unexpectedly expands the X-axis range from 1970 to 2024. This behavior did not occur in version 3.8.4, where the X-axis correctly ranges from 2020 to 2024.

Code for reproduction

import datetime
import matplotlib.pyplot as plt

x = [datetime.date(year, 1, 1) for year in range(2020, 2024)]
y = range(4)

plt.plot(x, y)
plt.axhspan(1, 2)

Actual outcome

3 9 0

Expected outcome

3 8 4

Additional information

No response

Operating system

Fedora

Matplotlib Version

3.9.0

Matplotlib Backend

inline or Agg

Python version

3.12.3

Jupyter version

4.2.1

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy