Skip to content

[Bug]: Empty bars are styled incorrectly in legend #27638

@rongcuid

Description

@rongcuid

Bug summary

When plotting multiple plots with specified colors, if plot data is empty, color parameter is ignored.

Code for reproduction

plt.figure()
plt.barh([], [], label="X", color="C0")
plt.barh([], [], label="Y", color="C1")
plt.legend()
plt.show()

Actual outcome

legend

Expected outcome

legend_expected

Additional information

No response

Operating system

No response

Matplotlib Version

3.8.2

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions