-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Streamplot supporting irregular grids with 2D x and y #12025
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
Comments
Just to add to this : If I do pass 2-D x + y arrays (same shape as the u + v) ...
That is nasty behaviour IMHO. Certainly, it had me thinking it did work, for a while ... 😊 😳 🤢 |
There is no reason that streamlines couldn’t be rewritten assuming non equal steps but it’d be a lot more code. Having it be a matrix of x and y points seems a lot harder. |
The streamplot example takes in 2D arrays for X,Y,U, and V. So is the example wrong? It looks good to me on first sight. Also, it produces the same output when X and Y are supplied as 1D arrays. What is the problem with 2D input that you experience? (A code with image and a description of undesired behaviour would be helpful for that.) Concerning the problem of irregular grids, one can always interpolate onto a regular grid first. Whether this is done by matplotlib internally or by the user externally does not make either way more or less efficient, only more convenient to use. |
Theoretically, the integration for making the streamplot need not be done on regularly spaced 1-d x/y grids. You just need to replace dx/dy = constant by a varying function. But the streamplot code is all written assuming dx/dy are constant; I'm not wholly convinced that the streamplot code could not be simplified a fair bit and made to accept vadying dx/dy, but thats not a project I'm going to take on. We could always make a regular grid for users, but I'd be against us doing that versus making the user do it because gridding data often requires some artistic license, and better to let the user decide what works best for them. |
I agree. There is no such thing as a general-purpose regrid algorithm. From our parochial point of view, we will generally be drawing our plots over maps with Cartopy. However, the existing facility still seems a bit clunky to me. |
I did not have time to read the post very carefully but there may be some implementation ideas here on unevenly gridded data (even though it is likely to be based in a rather old version of streamplot). |
One possible mechanism to integrate 1-step from
Additional processings like re-scaling the coordinates and velocities could also be important for getting optimal results. |
I'd love for this to be a possible feature, e.g. for streamlines of NEMO ocean data which has 2D lats and lons! Thanks. |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Commenting in the hopes that this can be revisited (do issues work like that)? The limitation of evenly-spaced data for |
Contour does not do any regridding. It just decides where between two consecutive points the contour should pass and doesn't care about how far apart any pair are. Streamplot could pretty readily do the same thing. But it would need to be rewritten. As noted above, I don't think regridding is necessary or even desirable. However it is likely that a more general code would best done in c rather than Python. |
Are there any plans to support streamplotting data on irregular grids?
Currently, the streamplot documentations states:
If my data is on an irregular grid, I currently have to interpolate to an evenly spaced grid before I can create a streamplot. This becomes a problem when the data is very large and interpolating takes a long time.
To add more roadbloacks, my x and y values are 2D arrays. Are there plans to support 2D x and ys as input to the streamplot?
(cc @pp-mo for reference)
The text was updated successfully, but these errors were encountered: