marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.03k stars 264 forks source link

incorrect color to display vtu file #834

Closed zhang-qiang-github closed 11 months ago

zhang-qiang-github commented 1 year ago

I have a vtu file, and vedo show it as:

image

In this figure, the red color indicate lower value than blue color, which is non-instinctive. Is it possible to make red color indicate the higher value?

The test data is:

flow.zip

zhang-qiang-github commented 1 year ago

In addition, when I set the color map to rainbow, the colorbar is weird.

mesh = Mesh('flow.vtu').add_scalarbar('pressure').cmap('rainbow')

show(mesh)

The result is:

image

The colorbar is not continuous. Why?

marcomusy commented 1 year ago

that's because you added the scalar bar before the cmap call (so you are actually building the scalarbar for some other vector data), try instead:

from vedo import * 
tmsh = TetMesh("flow.vtu")
msh = tmsh.tomesh(fill=False)
msh.cmap("rainbow", "Pressure").add_scalarbar()
show(msh, axes=1)
Screenshot 2023-03-18 at 15 34 32

you can invert any colormap name by adding _r, e.g. "rainbow_r"