Comments (4)
That was the issue, got it working...
Thank you!
from pyvista-support.
Using my example from #47 (comment)
import pandas as pd
import numpy as np
import pyvista as pv
##########
# Make a sample dataframe
df = pd.DataFrame()
df['x'] = np.array([0.0, 2.0])
df['y'] = np.array([0.0, 0.0])
df['z'] = np.array([0.0, 0.0])
df['x2'] = np.array([1.0, 2.0])
df['y2'] = np.array([0.0, 2.0])
df['z2'] = np.array([0.0, 0.0])
df['IDs'] = np.array(['Line ID 1', 'Line ID 2'])
##########
weaved = np.empty((len(df) * 2, 3))
weaved[0::2] = df[['x', 'y', 'z']].values
weaved[1::2] = df[['x2', 'y2', 'z2']].values
def lines_from_points(points):
"""Generates line from weaved points."""
n_points = len(points)
n_lines = n_points // 2
lines = np.c_[(2 * np.ones(n_lines, np.int),
np.arange(0, n_points-1, step=2),
np.arange(1, n_points+1, step=2))]
poly = pv.PolyData()
poly.points = points
poly.lines = lines
return poly
lines = lines_from_points(weaved)
lines.cell_arrays['IDs'] = df['IDs'].values
lines.plot(line_width=5)
You can then querry just like you would with any NumPy array. The details of string comparison in arrays becomes more of a general Python/NumPy question than a PyVista question.
indices = np.argwhere(lines['IDs'] == b'Line ID 2').ravel()
print(indices)
[1]
Once you have those indices, you could use to extract those cells by:
extracted = lines.extract_cells(indices)
extracted.plot(scalars='IDs')
from pyvista-support.
Not working...
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-36-1c9c705bd4e9> in <module>
----> 1 extracted = weaved.extract_cells(indices)
2 extracted.plot(scalars='Name')
AttributeError: 'PolyData' object has no attribute 'extract_cells'
from pyvista-support.
The extract_cells
filter was made available to all datasets on the last release - please make sure you are up to date in that environment/kernel
from pyvista-support.
Related Issues (20)
- create uniform mesh HOT 3
- Change the orientation of a scalar bar's title
- Applying textures on models from .obj files HOT 6
- How to create an Unstructured grid from points and faces HOT 2
- Type of data, plotting with glyphs HOT 3
- Controlling the thickness and orientation of a slice in Pyvista HOT 3
- Controlling the image position in window, without any click
- Mask/Remove Voxels in Air (small intersection with surface) HOT 3
- custom slider parameters
- running pyvista on headless machine with Centos OS HOT 1
- Seismic Horizon with Pyvista HOT 8
- Algorithm in sample function?
- Automatically updates HOT 3
- Slow interaction HOT 1
- read from text HOT 4
- Uniform Grid thresholding question HOT 8
- Take data by an input x,y,x coordinate (csv file) from vtk data file HOT 4
- Program broke when creating a mesh using pv.PolyData() HOT 4
- ATTENTION: Please move questions to PyVista's Discussions HOT 1
- plotter.enable_terrain_style not working for me HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvista-support.