8000 [Bug]: Inconsistent Visualization of Intervals in ax.barh for Different Duration Widths · Issue #28223 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: Inconsistent Visualization of Intervals in ax.barh for Different Duration Widths #28223
Closed
@AndreasLR

Description

@AndreasLR

Bug summary

Issue Description:

When using ax.barh to visualize intervals, the function fails to display all intervals under certain conditions, which appears to be linked to the width of the intervals specified as duration. Specifically, intervals with a duration of 3 hours are not displayed properly, while increasing the duration to 5 hours results in 7137 correct visualization. This issue suggests a potential problem with how interval widths are handled or rendered in ax.barh.

Steps to Reproduce:
Refer to "code for reproduction"

Expected Behavior:

All intervals should be visualized consistently, regardless of their duration width.

Actual Behavior:

Intervals with a shorter duration (3 hours) are not visualized correctly, while longer durations (5 hours) are displayed as expected.

Code for reproduction

from datetime import datetime, timedelta
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

duration = timedelta(hours=3)
# duration = timedelta(hours=5)
ax.barh(y=0, width=duration, left=datetime(2024, 1, 1, 6))
ax.barh(y=1, width=duration, left=datetime(2024, 1, 1, 1))

plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig('bug.png')

Actual outcome

Only one of two bars is rendered.
image

Expected outcome

I expect both bars to appear:
image

Additional information

No response

Operating system

Ubuntu and Manjaro

Matplotlib Version

3.8.4

Matplotlib Backend

agg

Python version

3.11.8

Jupyter version

No response

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

      0