GithubHelp home page GithubHelp logo

Color by distance about pyvista-support HOT 6 CLOSED

pyvista avatar pyvista commented on July 18, 2024
Color by distance

from pyvista-support.

Comments (6)

laserman781 avatar laserman781 commented on July 18, 2024 1

Never mind I solved the issue, thanks!

from pyvista-support.

banesullivan avatar banesullivan commented on July 18, 2024 1

Make sure to index the data frame with the same conditional when grabbing the shortest distance array as you do when you grab the points. Better yet, Iā€™d make an indexing array:

q=50
indices = points['shortest distance']<=q
points_array = points[indices][['x', 'y', 'z']].values
bpoly = pv.PolyData(points_array)
bpoly['shortest distance'] = points[indices]['shortest distance'].values

Sent with GitHawk

from pyvista-support.

banesullivan avatar banesullivan commented on July 18, 2024

When using the Plotter, all you should need to do is specify the colormap in the add_mesh call instead of the color argument. Sounds like you want to use the 'coolwarm_r' colormap but any Matplotlib colormap is supported

Try this:

p = pv.Plotter()
p.add_mesh(bpoly.clip(normal='z',
        origin=[0,0,clip_pts]), 
    cmap='coolwarm_r',
    render_points_as_spheres=True)
p.show()

Sent with GitHawk

from pyvista-support.

laserman781 avatar laserman781 commented on July 18, 2024

@banesullivan by adding cmap = 'coolwarm_r' to the add_mesh the points are all white and don't change by distance...

from pyvista-support.

banesullivan avatar banesullivan commented on July 18, 2024

Hm, do you have scalars on the mesh? Maybe make sure:

points_array = points[['x', 'y', 'z']].values
poly = pv.PolyData(points_array)
poly['shortest distance'] = points['shortest distance'].values

p = pv.Plotter()
p.add_mesh(poly.clip(normal='z',
        origin=[0,0,clip_pts]), 
    cmap='coolwarm_r',
    scalars='shortest distance',
    render_points_as_spheres=True)
p.show()

Sent with GitHawk

from pyvista-support.

laserman781 avatar laserman781 commented on July 18, 2024

It worked after I defined the scalar as shortest distance. Now my problem is, I want to filter for blocks within a specified distance and after trying to include the color map is get this error:

Exception: Number of scalars (153813)must match either the number of points (4910) or the number of cells (4910).

Code:

q=50
points_array = points[points['shortest distance']<=q][['x', 'y', 'z']].values
bpoly = pv.PolyData(points_array)
bpoly['shortest distance'] = points['shortest distance'].values

from pyvista-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.