Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Patchcollection keeps original patch#22814

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
hhalwan wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromhhalwan:patchcollection-keeps-original-patch

Conversation

hhalwan
Copy link

PR Summary

Fixesthis issue. PatchCollection currently ignores the hatches of the provided patches, only allowing a hatch passed as a keyword into the constructor. If match_original is true, we now keep the hatch of the first patch provided in the collection, rather than using the hatch passed as a keyword into the constructor. Edited the doc strings to reflect this. Additionally, the hatchcolor is determined by the edge color, so we will only initialize the collection with the edgecolors of the patches if the edgecolor is not blank - its default color of [0, 0, 0, 0]. This ensures that the hatch will use its default of black in the case where no edgecolor of the patches is ever set.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • [n/a] New features are documented, with examples if plot related.
  • [n/a] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

…llection.PatchCollection will currently ignore hatches of the provided patches, only allowing a hatch passed as a keyword into the constructor. If match_original is true, we now keep the hatch of the first patch provided in the collection. Additionally, the hatchcolor is determined by the edge color, so we will only pass the edgecolors of the patches to the Collection if the edgecolor is not blank - its default color of [0, 0, 0, 0]. This ensures that the hatch will use its default of black in the case where no edgecolor of the patches was ever set.
…r a PatchCollection when match_original is true.
Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping@matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@oscargusoscargus added status: needs workflow approvalFor PRs from new contributors, from which GitHub blocks workflows by default. topic: collections and mappables labelsApr 10, 2022
@tacaswelltacaswell added this to thev3.6.0 milestoneApr 10, 2022
kwargs['linewidths'] = [p.get_linewidth() for p in patches]
kwargs['linestyles'] = [p.get_linestyle() for p in patches]
kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
if patches:
kwargs['hatch'] = patches[0].get_hatch()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If we are going to only pick of the hatch from the first patch, then we should warn or raise if we are going to ignorethe rest of the hatches.

Copy link
Author

@hhalwanhhalwanApr 12, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why? If that's true, it would be impossible to make a collection of multiple patches w/ hatches without getting a warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

sorry I was not clear. The check should be "are all of the hatches the same? if so carry on, if not fail!" As implemented if the user passes in

[mpatches.Rectangle((0,0),0.2,.2,hatch="/"),mpatches.Rectangle((0.4,0.4),0.2,.2,hatch="\\")]

then the first hatch will be used for both and we will silently drop the"\\" on the second one!

@@ -1827,12 +1828,20 @@ def determine_facecolor(patch):
if patch.get_fill():
return patch.get_facecolor()
return [0, 0, 0, 0]

def is_default(c):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This in only the default default (that is, there is a set of rcparams which will cause this to be miss. Looking at

def_set_edgecolor(self,color):
set_hatch_color=True
ifcolorisNone:
if (mpl.rcParams['patch.force_edgecolor']or
notself._fillorself._edge_default):
color=mpl.rcParams['patch.edgecolor']
else:
color='none'
set_hatch_color=False
self._edgecolor=colors.to_rgba(color,self._alpha)
ifset_hatch_color:
self._hatch_color=self._edgecolor
self.stale=True
defset_edgecolor(self,color):
"""
Set the patch edge color.
Parameters
----------
color : color or None
"""
self._original_edgecolor=color
self._set_edgecolor(color)
we have some private state (which we are allowed to use inside of Matplotlib) to check this. In this case, I think it is better to checkp._original_edgecolor and ifNone either re-implement the default logic or pass inNone here (if we can) and let the next layer down deal with resolving the default behavior.

@tacaswell
Copy link
Member

Thank you for working on this@hhalwan and apologies for the delay in getting this reviewed.

Do my comments make sense?

…h._original_edgecolor to see if edgecolors were set.
@oscargusoscargus added status: needs review status: needs rebase and removed status: needs workflow approvalFor PRs from new contributors, from which GitHub blocks workflows by default. labelsAug 2, 2022
hatch = patches[0].get_hatch()
kwargs['hatch'] = hatch
if any(p.get_hatch() != hatch for p in patches):
warnings.warn("More than one type of hatch detected in "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should use_api.warn_external? Also should be tested.

@QuLogicQuLogic modified the milestones:v3.6.0,v3.7.0Aug 24, 2022
@timhoffm
Copy link
Member

@hhalwan do you plan to come back to this?

@hhalwan
Copy link
Author

hhalwan commentedSep 27, 2022
edited
Loading

@timhoffm I don't have time right now, I'm happy to let someone else take it up.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@QuLogicQuLogicQuLogic left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
Status: Needs decision
Milestone
future releases
Development

Successfully merging this pull request may close these issues.

[Bug]: PatchCollection fails to keep hatch from Patch
5 participants
@hhalwan@tacaswell@timhoffm@QuLogic@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp