Skip to content

[Bug]: PatchCollection fails to keep hatch from Patch #22654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GYHHAHA opened this issue Mar 16, 2022 · 2 comments · May be fixed by #27937 or #22814
Open

[Bug]: PatchCollection fails to keep hatch from Patch #22654

GYHHAHA opened this issue Mar 16, 2022 · 2 comments · May be fixed by #27937 or #22814

Comments

@GYHHAHA
Copy link

GYHHAHA commented Mar 16, 2022

Bug summary

When using add_collection to add Patches, hatch attribute isn't able to kept, whereas add_patch is fine.

Code for reproduction

from matplotlib.patches import Rectangle
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
fig, ax = plt.subplots(figsize=(4,4))
patches = [
    Rectangle((0, 0), 0.2, .2, facecolor="orange", hatch="/")
]
collected_patches = PatchCollection(patches, match_original=True)
ax.add_collection(collected_patches)
ax.add_patch(Rectangle((0.8, 0.8), 0.2,0.2, facecolor="skyblue", hatch="/"))

Actual outcome

output

Expected outcome

output2

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

@Impaler343
Copy link
Contributor

Hey, I was looking to solve this issue, and according to this PR, we are trying to use only one hatch for all patches based on the first patch, but what if we needed to use different hatches for different patches? This would not be possible. Could someone elaborate on why we shouldn't be implementing it in the second way?

@timhoffm
Copy link
Member

timhoffm commented Mar 8, 2024

@Impaler343 You are correct. That PR is too simple (well it would have been a step in the right direction). Fundamentally, we'd want individual hatches.

@Impaler343 Impaler343 linked a pull request Mar 16, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants