Just in case someone else hits this thread later... all I needed for a blue-to-red rainbow lookuptable was:<div><br></div><div><div> lut = vtk.vtkLookupTable()</div><div> lut.SetHueRange(0.667, 0.0)</div><div> lut.SetNumberOfColors(256)</div>
<div> lut.Build()</div><div><br></div><div>Now... since Andrew pointed me to that great paper by Ken let's discuss colormaps a bit! Firstly, that was a great paper... definitely well done. Unfortunately, I can't agree completely with the conclusions.</div>
<div><br></div><div>If every person on earth was a scientist or engineer... then we should all take Ken's advice and use Blue-to-Red Diverging for our colormaps. Unfortunately, that's not the case! So while a diverging colormap might convey detail better to a scientist or engineer who is familiar with the domain... many times visualizations are shown to people who have no real background on the material... and in those cases they want to see _color_... and I don't just mean a bit of red and a bit of blue with some grey in between... they want to see a LOT of color.</div>
<div><br></div><div>The people I'm talking about here are the program managers and senators and bosses and even customers.... the people we depend on to give us money so we can continue to do science! When those people are in the room I want to catch their eye with over saturated rainbows of color... even if a bit of detail is lost in the green areas ;-)</div>
<div><br></div><div>Only after catching their eye can I even attempt to explain the science behind what they're seeing and convince them to give me more money to study it further. If they're turned off by boring colors from the start I might never get the chance....</div>
<div><br></div><div>Just my 2 cents ;-)</div><div><br></div><div>Derek</div><br><div class="gmail_quote">On Mon, Jul 2, 2012 at 4:37 PM, Andrew Maclean <span dir="ltr"><<a href="mailto:andrew.amaclean@gmail.com" target="_blank">andrew.amaclean@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div> Hi Derek,</div><div> You might like to look at: <a href="http://www.vtk.org/Wiki/VTK/Examples/Python/CurvaturesDemo" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Python/CurvaturesDemo</a></div>
<div>
This shows you how to use a diverging colour space very nicely!</div><div>To choose other colour spaces and to extend this look at the C++ code referred to in the document <a href="http://www.cs.unm.edu/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf" style="font-size:12px;line-height:18px;text-align:left;color:rgb(0,102,153);text-decoration:none;margin:0px;padding:0px;vertical-align:baseline;outline:none" target="_blank">http://www.cs.unm.edu/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf</a> by Kenneth Moreland, this is a very good article.</div>
<div><br></div><div>Regards</div><div> Andrew</div><div><div class="h5"><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---------- Forwarded message ----------<br>
From: Derek Gaston <<a href="mailto:friedmud@gmail.com" target="_blank">friedmud@gmail.com</a>><br>To: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>Cc: <br>Date: Sun, 1 Jul 2012 15:15:53 -0600<br>
Subject: [vtkusers] Change Contour Colors<br>
Hello all.<div><br></div><div>I'm writing a bit of custom Python with Qt and VTK to add some visualization to a small PyQt GUI we have.</div><div><br></div><div>I need to read ExodusII and just do some simple contour plotting of what's in there with a color scale/legend (I also draw the edges so you can see the mesh). I have it basically working at this point (although hardcoded to a specific variable name... but I'll change that later). But I'm hung up at trying to change the colors of the contours.</div>
<div><br></div><div>All I want is very simple. Right now it generates from Red to Blue (low to high)... all I need is for it to go from Blue to Red (BTW - why the heck is Red to Blue the default... shouldn't Blue to Red be the default? I think most people associate Red with a high color... especially if you are plotting temperature... but that's beside the point).</div>
<div><br></div><div>I've looked at vtkLookupTable and vtkColorTransferFunction... but I can't seem to come up with the right magic. Basically, what I want is just the simple Blue to Red HSV color bar that you can get in Paraview by choosing that preset. Any help would be awesome!</div>
<div><br></div><div>Here is my current code (it's in a Python class that inherits from QWidget and uses a QVTKWidget2 that is initialized elsewhere):</div><div><br></div><div><br></div><div><div><br></div><div><div> self.file_name = file_name</div>
<div> reader = vtk.vtkExodusIIReader()</div><div> reader.SetFileName(self.file_name)</div><div> reader.UpdateInformation()</div><div> reader.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL, 1)</div><div> reader.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL_TEMPORAL, 1)</div>
<div> reader.SetTimeStep(1)</div><div> reader.Update()</div><div><br></div><div> cdp = vtk.vtkCompositeDataPipeline()</div><div> vtk.vtkAlgorithm.SetDefaultExecutivePrototype(cdp)</div><div><br></div><div> geom = vtk.vtkCompositeDataGeometryFilter()</div>
<div> geom.SetInputConnection(0,reader.GetOutputPort(0));</div><div> geom.Update()</div><div><br></div><div> data = geom.GetOutput()</div><div> data.GetPointData().SetScalars(data.GetPointData().GetArray("u"))</div>
<div> mapper = vtk.vtkPolyDataMapper()</div><div> mapper.SetInput(data)</div><div> mapper.ScalarVisibilityOn()</div><div> mapper.SetColorModeToMapScalars()</div><div> mapper.SetColorMode(2)</div><div> mapper.SetScalarRange(0,1.0)</div>
<div><br></div><div> actor = vtk.vtkActor()</div><div> actor.SetMapper(mapper)</div><div> self.renderer.AddActor(actor)</div><div><br></div><div> edge_geom = vtk.vtkCompositeDataGeometryFilter()</div><div> edge_geom.SetInputConnection(0,reader.GetOutputPort(0));</div>
<div> edge_geom.Update()</div><div><br></div><div> edges = vtk.vtkExtractEdges()</div><div> edges.SetInput(edge_geom.GetOutput())</div><div> edge_mapper = vtk.vtkPolyDataMapper()</div><div> edge_mapper.SetInput(edges.GetOutput())</div>
<div><br></div><div> edge_actor = vtk.vtkActor()</div><div> edge_actor.SetMapper(edge_mapper)</div><div> edge_actor.GetProperty().SetColor(0,0,0)</div><div><br></div><div> self.renderer.AddActor(edge_actor)</div>
<div><br></div><div> scalar_bar = vtk.vtkScalarBarActor()</div><div> scalar_bar.SetLookupTable(mapper.GetLookupTable())</div><div> scalar_bar.SetTitle("u")</div><div> scalar_bar.SetNumberOfLabels(4)</div>
<div><br></div><div> self.renderer.AddActor2D(scalar_bar)</div><div><br></div><div> # Avoid z-buffer fighting</div><div> vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset()</div><div><br></div>
<div>
<br></div><div> self.renderer.ResetCamera()</div><div> self.vtkwidget.updateGL()</div></div></div><div><br></div>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br>___________________________________________<br>Andrew J. P. Maclean<br><br>___________________________________________<br>
</font></span></blockquote></div><br></div>