[Paraview] Rescale to data range on a field's component in python in Paraview 4.3.1

Christophe Bourcier christophe.bourcier.pv at gmail.com
Mon May 18 09:31:53 EDT 2015


Hi,

In 4.2.0, the following code was enough to display a field's component
instead of its magnitude and set the right scalar bar:

lookup_table = GetColorTransferFunction('SIGM')

#change array component used for coloring
id_comp = 2
lookup_table.VectorComponent = id_comp
lookup_table.VectorMode = 'Component'


In 4.3.1, we have to explicitly get the min and max of the field and
change the scalar bar name:

# Update the scalar bar range
source_array = stress.PointData.GetArray("SIGM")
comp_name = source_array.GetComponentName(id_comp)
mini, maxi = source_array.GetComponentRange(id_comp)
lookup_table.RGBPoints = [mini, r, g, b, maxi, r2, g2, b2]

# Update the scalar bar name
ScalarBar1 = GetScalarBar(lookup_table)
SetProperties(ScalarBar1, ComponentTitle=comp_name)

Is this a bug, or am I missing something?

In attachment, a script to load in Paraview 4.2.0 and 4.3.1. The
sample file can be downloaded here: http://bourcier.eu/stress.vtu

Thanks.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stress_field_vtu.py
Type: text/x-python
Size: 1447 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150518/d24350db/attachment.py>


More information about the ParaView mailing list