Skip to content

Cleanup tripcolor() #22356

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

Merged
merged 3 commits into from
Mar 29, 2022
Merged

Cleanup tripcolor() #22356

merged 3 commits into from
Mar 29, 2022

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Jan 29, 2022

PR Summary

Commits:

  • Rewrite Triangulation.get_from_args_and_kwargs to make parameter parsing testable; and add tests.
  • Warn when passing triangles or mask alongside a Triangulation to tripcolor()
  • Cleanup logic and documentation of tripcolor()
    This issues additional warnings and more precise error messages but does not change behavior.
    The only "semantic" change is that I have discouraged passing triangles positionally: tripcolor(x, y, triangles, C)
    is a bit odd and IMHO has too many positional arguments.

Closes #22303. Follows up on #10148.

@timhoffm timhoffm force-pushed the triplot branch 3 times, most recently from 382eca7 to a8b9429 Compare January 29, 2022 23:31
@timhoffm timhoffm changed the title Triplot Cleanup tripcolor() Jan 29, 2022
@timhoffm timhoffm added this to the v3.6.0 milestone Jan 29, 2022

collection = PolyCollection(verts, **kwargs)

collection.set_alpha(alpha)
collection.set_array(C)
collection.set_array(colors)
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, probably kwargs should be set last, for the same reason as in #21146/#21525?

Copy link
Member Author

Choose a reason for hiding this comment

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

But there is collection._scale_norm(norm, vmin, vmax) after setting the norm here. AFAICS this handles the issue in #21146/#21525. One can probably remove that when delaying kwargs setting. But since this PR is already complicated enough and there is no immediate problem, I'd not go into this within this PR.

@timhoffm timhoffm force-pushed the triplot branch 2 times, most recently from be7e1e2 to ef81739 Compare March 27, 2022 07:50
This issues more and more precise warnings on usage errors but does not
change behavior.

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@QuLogic QuLogic merged commit dfd83c2 into matplotlib:main Mar 29, 2022
@QuLogic
Copy link
Member

QuLogic commented Mar 29, 2022

Oops, thought there was a second review; hope you're okay with this @anntzer?

@anntzer
Copy link
Contributor

anntzer commented Mar 29, 2022

No worries, opened #22726 to track the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Args for tripcolor
3 participants