CFD Online Discussion Forums

CFD Online Discussion Forums (
-   ParaView (
-   -   Python script: Auto-scale color scale (

julien.decharentenay December 3, 2013 20:50

Python script: Auto-scale color scale

I am puzzled as to how to auto-scale the color scale when using python script to load and display variables.

When saving to a Python script, the RGBPoints variable explicitly nominates the upper and lower scale values (and associated colors) as shown below:


integrationTime_PVLookupTable = GetLookupTableForArray( "IntegrationTime", 1, Discretize=1, RGBPoints=[-0.722103597630862, 0.23, 0.299, 0.754, 0.5209744105817566, 0.706, 0.016, 0.15], UseLogScale=0, VectorComponent=0, NanColor=[0.25, 0.0, 0.0], NumberOfTableValues=256, EnableOpacityMapping=0, ColorSpace='Diverging', IndexedLookup=0, VectorMode='Magnitude', ScalarOpacityFunction=integrationTime_PiecewiseFunction, HSVWrap=0, ScalarRangeInitialized=1.0, AllowDuplicateScalars=1, Annotations=[], LockScalarRange=0 )
Is there a easy way to have autoscaling or retrieve the upper and lower field limits from the Python script?

wyldckat December 8, 2013 15:17

Hi Julien,

Have a look into this post: post #6

Best regards,

julien.decharentenay December 9, 2013 06:39

Thanks Bruno. You're a champ - as usual.

I actually went through the thread as I was looking for a solution, but missed it (wrong assumption that it was more relevant for GUI based operation)...

For my reference, the bit of code is as follows:


    data = source.GetCellDataInformation()
    #data = source.GetPointDataInformation()

    #get the array and the respective min-max
    array = data.GetArray(arrayName)
    dataRange = array.GetRange(component)

    lookupTable.LockScalarRange = 1

    #Now let's hack in the range values
    lookupTable.RGBPoints[0] = dataRange[0] #min
    lookupTable.RGBPoints[4] = dataRange[1] #max

All times are GMT -4. The time now is 22:09.