Skip to content

[Bug]: PathCollection using alpha ignores 'none' facecolors #27839

@subsurfaceiodev

Description

@subsurfaceiodev

Bug summary

As title, using alpha parameter in PathCollection, either as a list or as a scalar value, causes 'none' facecolors to be ignored / filled

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.collections import PathCollection
from matplotlib.path import Path

# https://matplotlib.org/stable/gallery/shapes_and_collections/compound_path.html

paths = [
    Path(
        [(1, 1), (1, 2), (2, 2), (2, 1), (0, 0)],
        [Path.MOVETO] + [Path.LINETO] * 3 + [Path.CLOSEPOLY]
    ),
    Path(
        [(4, 4), (5, 5), (5, 4), (0, 0)],
        [Path.MOVETO] + [Path.LINETO] * 2 + [Path.CLOSEPOLY]
    ),
]

fig, ax = plt.subplots()
collection = PathCollection(
    paths,
    edgecolors='black',
    facecolors=['blue', 'none'],
    alpha=[1, 1],
    # alpha=1
)
collection.set_transform(ax.transData)
ax.add_artist(collection)
ax.set(xlim=(0, 5), ylim=(0, 5))
plt.show()

Actual outcome

actual

Expected outcome

expected

Additional information

No response

Operating system

Windows

Matplotlib Version

3.8.3

Matplotlib Backend

No response

Python version

3.12

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