pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
59 stars 4 forks source link

Plotting surfaces in different colors #509

Closed julienfranz closed 2 years ago

julienfranz commented 3 years ago

I have a .mesh file having 2 arrays (each corresponds to the interior and exterior part of the mesh): e.g,

--

Header Data Arrays
UnstructuredGridInformationN Cells29111N Points5435X Bounds-8.884e-01, 8.861e-01Y Bounds-1.095e+00, 1.167e+00Z Bounds-1.000e+00, 1.267e+00N Arrays2 N Cells 29111 N Points 5435 X Bounds -8.884e-01, 8.861e-01 Y Bounds -1.095e+00, 1.167e+00 Z Bounds -1.000e+00, 1.267e+00 N Arrays 2 NameFieldTypeN CompMinMaxmedit:refPointsfloat6410.000e+003.000e+00medit:refCellsint6410.000e+003.000e+00 medit:ref Points float64 1 0.000e+00 3.000e+00 medit:ref Cells int64 1 0.000e+00 3.000e+00

N Cells | 29111 N Points | 5435 X Bounds | -8.884e-01, 8.861e-01 Y Bounds | -1.095e+00, 1.167e+00 Z Bounds | -1.000e+00, 1.267e+00 N Arrays | 2

medit:ref | Points | float64 | 1 | 0.000e+00 | 3.000e+00 medit:ref | Cells | int64 | 1 | 0.000e+00 | 3.000e+00

--

Now, how do I plot the two surfaces in different colors? Thank you.

akaszynski commented 3 years ago

It's a bit hard to tell what's going without a code example, but if I wanted to plot two different meshes with two different colors, I'd:

import pyvista
pyvista.set_plot_theme('document')

mesh_a = pyvista.Sphere(center=(1, 0, 0))
mesh_b = pyvista.Cube()

pl = pyvista.Plotter()
pl.add_mesh(mesh_a, color='r', smooth_shading=True)
pl.add_mesh(mesh_b, color='b')
pl.show()

sc