-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MNT]: #28701 separate the generation of polygon vertices in fill_between to enable resampling #28702
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
[MNT]: #28701 separate the generation of polygon vertices in fill_between to enable resampling #28702
Conversation
There was a problem hiding this 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 week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
I'm somewhat skeptical we would expose this publicly. The point here is to want to be able to change the x and y data. If I were to do this I'd change the polygon patch to a polygon patch subclass and have set_x/ydata methods that do the "right thing". |
Hi @jklymak thank you for the comment.
I am not sure what you mean here, especially the "polygon patch". Could you elaborate? Furthermore, would it be more acceptable if we make separate methods of |
Currently I think that is what @jklymak meant, and he just temporarily forgot that it's a collection rather than an single patch. |
Hi @rcomer thank you for the reply.
|
matplotlib/lib/matplotlib/lines.py Lines 647 to 666 in 1e98377
So for API consistency it would make sense to have a collection that implements all three ( I agree that it would be more work to implement a new subclass, but I do not think that is more important than providing a consistent API for users. Are there any current axes methods that purely translate data to be used in a specific type of plot? |
Perhaps another option would be to put something in |
Yes there is no way we would allow a helper like this to be a method on Axes. A subclass is relatively trivial and could admit an API similar to the fill_between API |
Hi, thank you for the discussions. I would like to have some further assistance before continue.
|
I think
|
… exposing internal data matplotlib#28702 (comment)
The end goal, I think, is fb = ax.fill_between(x, y1, y2, where=where)
...
fb.set_data(newx, newy1, newy2, where=newwhere) or fb = ax.fill_between(y, x1, x2, where=where)
...
fb.set_data(newy, newx1, newx2, where=newwhere) I appreciate that this is more complicated than a helper to generate the vertices of the polygons and then passing that to a PolygonCollection.set_verts, but it is quite a bit more friendly to the end user who need not know anything more about the PolygonCollection. A lot of |
Hi @jklymak, thank you for giving an outlook.
The code already looks like this for now. Maybe I can make a
I also believe that the code already looks like this now. What still remains in # now update the datalim and autoscale
self.update_datalim(collection._pts, updatex=up_x, updatey=up_y)
self.add_collection(collection, autolim=False)
self._request_autoscale_view() that is not needed when we |
At a quick glance, this looks great, but others should chip in before polishing up. Perhaps @timhoffm and @antzer as API and tech leads? Can I suggest you add an example that uses |
High-level feedback:
I'm overall +0.5 on this, but would like to get feedback on the paradigm shift towards semantic artists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe, this is ready after handling this round of review comments. 🎉🎉🎉
Thanks for digging this up. That convinces me that we can use it here (even though I feel we need to reconsider this pattern mid-term). |
Update doc/users/next_whats_new/fill_between_poly_collection.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
…nerating-vertices
Update doc/users/next_whats_new/fill_between_poly_collection.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@cmp0xff please change the line numbers in the following places from 120 to 121: matplotlib/doc/missing-references.json Lines 307 to 308 in 54d718e
and matplotlib/doc/missing-references.json Lines 321 to 322 in 54d718e
Also add This should fix the doc build. Having to track the missing references by line number is an unsatisfactory workaround, but a fundamental fix for the issue is somewhat involved. |
…nerating-vertices
…nerating-vertices
Thank you @cmp0xff and congratulations on your first merged Matplotlib PR 🎉 I hope we hear from you again! |
PR summary
closes #28701:
fill_between
, we can extract functionalities to generate the polygon coordinates only.class FillBetweenPolyCollection
to collect related functionalities.fill_between
to make it easier to understand.PR checklist