Skip to content

[ENH]: A function for computing and displaying 3D streamline? #26539

Open

Description

@xli2522

Problem

Worth adding a function for computing and displaying 3D stream plots?

A 3D version of the streamline plot function pyplot.streamplot would display the streamlines in 3D vector fields. This is doable in Matplotlib by computing everything beforehand and displaying the results in 3D, but it would be a lot simpler if Matplotlib had a function that does everything. This function would be especially useful for displaying magnetic field streamlines in 3D.

Similar functions in Mayavi , Magpylib via Pyvista, and Mathematica.

Proposed solution

No response

Activity

  1. scottshambaugh commented on Aug 17, 2023

    @scottshambaugh
    Contributor

    Definitely useful! I think we would need us to think about how best to tie this in with the 2D implementation in https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/streamplot.py

    I'm a little uncomfortable with how we are currently abstracting away all the streamline calculations - there's a lot of nuance about integrator settings that we are brushing under the rug. For example I think using only a 2nd order runge-kutta method right now for integration is a bit of a questionable choice, as is using a linear interpolator, and boundary conditions aren't configurable at all. But the very nature & sparsity of a streamline plot does suggest that it's just an approximate visualization, so maybe this is fine. Shouldn't preclude adding in a basic implementation in any case.

  2. jklymak commented on Aug 17, 2023

    @jklymak
    Member

    I would start with an external package for this, and then we can see if we can work it in. In particular I would be much more concerned about speed and how to make it look reasonable than accuracy.

  3. scottshambaugh commented on Aug 17, 2023

    @scottshambaugh
    Contributor

    @jklymak do you know of an external package for this? I did a quick search but couldn’t find anything. If I recall correctly how it worked with the contour package we pull in, that it started in matplotlib and split off after it got to a point of high enough maturity.

  4. jklymak commented on Aug 17, 2023

    @jklymak
    Member

    I meant I would suggest writing an external package.

    contouring was split off because it is a more general problem than just Matplotlib, and now other libraries can use it. If we were doing it again, I suspect we would have started out that way. Similarly here - calculating streamlines is complex, and somewhat dependent on the underlying physics, so developing the code outside of Matplotlib may make sense, and then we could make it a dependency eventually if there is a simple API that can be used.

  5. haricash commented on Nov 21, 2023

    @haricash

    Seconding this - I would love a 3D streamplot feature for Matplotlib. Is there any work being done in this direction?

  6. Gritbadger commented on Nov 29, 2023

    @Gritbadger

    I need a function to draw ternary streamplot. I know a package python-ternary can draw ternary diagrams, but it can't draw stream plot. Can anyone help me?

  7. scottshambaugh commented on Dec 22, 2024

    @scottshambaugh
    Contributor

    Some updates to the 2D implementation: #29333

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions