Skip to content
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

Create a 2D matplotlib plot from Slices #341

Closed
jacobgrasmick opened this issue Jan 13, 2021 · 4 comments
Closed

Create a 2D matplotlib plot from Slices #341

jacobgrasmick opened this issue Jan 13, 2021 · 4 comments
Assignees

Comments

@jacobgrasmick
Copy link

Say I create a slice via the Slicing tools:
https://docs.pyvista.org/examples/01-filter/slicing.html?highlight=slicing

I would like to be able to achieve any of the following:

  1. extract a numpy array of the slice(s)
  2. plot a slice in a 2D plot such as matplotlib

I can see this being a challenge if the slice is generated via slice_along_line...

@banesullivan banesullivan self-assigned this Jan 14, 2021
@banesullivan
Copy link
Member

There are a few examples of doing this with a planar slice: see #70 and #89

As for doing this with a curvilinear slice produced from slice_along_line that is a bit more complex but doable. I will come back to this (hopefully this evening) to post an example.

@Dementiy
Copy link

Hello.

This question is still relevant. How to get the right order of points from slice that was created by slice_along_line?

Matplotlib 2D (using points attribute from slice):
image

Pyvista 3D (everything looks good):
image

@banesullivan
Copy link
Member

I believe the problem is that you are projecting the 3D line onto a 2D plane in your Matplotlib plot, that's why you see the line going back on itself...( from an quick glance)

@Dementiy
Copy link

Hi, @banesullivan , thanks for the reply. I got the answer in this discussion pyvista/pyvista#2798 there is a more suitable example.

@pyvista pyvista locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants