[Paraview] Setting color maps in python

Scott, W Alan wascott at sandia.gov
Mon Mar 23 19:25:21 EDT 2015


With a lot of help from Utkarsh, I now know how to set custom color maps in Python.  Here is what I did, and the code, for coloring Sources/ Wavelet by the blue to red rainbow.  (And has been said, blue to red rainbow is a poor color map for doing real work.  It does create pretty pictures, however.)

ParaView 4.3.1, local server, Linux.
Sources/ wavelet/ apply.  Change outline to surface.  Paint by RTData.
Color editor.  Preset - Blue to Red Rainbow.  Export.  Save this as an xml file somewhere you can find it.
Edit this .xml file.  There will be two ColorMaps (unless this has been fixed).  Delete the second group (from ColorMap to /ColorMap).  Also, delete the two lines with ColorMaps in them.
(Note - I will write up bugs for these two issues.)

Edit/ reset session.
Tools/ Start Trace.  OK.
Sources/ Wavelet.  Apply. Change outline to surface.  Paint by RTData.
Tools/ Stop Trace.

Save the script.

Edit the script.  Below the line where it says wavelet1Display.SetScalarBarVisibility(renderView1, True), add the following:

lut = GetColorTransferFunction("RTData")
with open("/..../junkDir/blue-to-red-rainbow.xml", "r") as f:
      data = f.read()
      lut.ApplyColorMap(data)



Then, comment out the two lines that say:
# get color transfer function/color map for 'RTData'
rTDataLUT = GetColorTransferFunction('RTData')

# get opacity transfer function/opacity map for 'RTData'
rTDataPWF = GetOpacityTransferFunction('RTData')



Save your file, then in ParaView do the following:
Edit/ reset session.
Tools/ Python shell.  Run script.

Alan



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150323/54b9c128/attachment.html>


More information about the ParaView mailing list