Re: Density Plot coloring issue

*To*: mathgroup at smc.vnet.net*Subject*: [mg79749] Re: Density Plot coloring issue*From*: Yvon <ymgrigsb at yahoo.com>*Date*: Fri, 3 Aug 2007 06:31:18 -0400 (EDT)*References*: <f8s3jr$3j6$1@smc.vnet.net>

I found one error in my formula, but this doesn't seem to fix the overall problem. Also, I noticed it did something wierd to the data density code when I pasted it into the original post. So I will repaste below with the fix to my GetColor function and cleaned up code. The index could be returned as 0 which there is no such thing in my CellColor table. A simple if statement fixed that. But I'm still coming up with cells that are white for the max value and minimum above 0 even though the color function has returned the expected color. cList = {{6.75, 5.85, 0., 6.39, 7.41, 0.}, {6.4, 5.57, 0., 6.6, 6.68, 0.}, {5.99, 5.51, 0., 6.24, 6.37, 0.}, {6.1, 5.72, 3.93, 5.92, 5.89, 0.}, {5.71, 5.85, 6.05, 5.92, 6.06, 0.}, {5.62, 5.64, 5.61, 5.42, 5.14, 0.}, {0, 0, 0, 0, 0, 0}} numColors = 10 minLWC = 0 maxLWC = 10 CellColor[index_] := Module[{cTable, s}, (*White,purple,blue, light blue, light green, kahki, light yellow, light orange, pink, red *) cTable = {{1, 1, 1}, {0.5, 0, 0.5}, {0.4, .6, 0.9}, {0.7, .9, .96}, {.8, 1, .7}, {.6, 0.8, .2}, {1, 1, 0.5}, {1, .84, 0}, {1, .75, .8}, {. 86, .08, .24}}; s = Partition[Map[RGBColor, cTable], 1]; RGBColor[cTable[[index]]] ] (*Create a separate function with one parameter x = index called from previous function that returns RGBColor object*) GetColor[x_] := (p = Round[Abs[(x - min)*numColors/(max - min)]] ; If[p == 0, p = 1, p]; CellColor[p]); ListDensityPlot[lData, InterpolationOrder -> 0, ColorFunction -> GetColor, ColorFunctionScaling -> {False}, Mesh -> {numCols - 1, numRows - 1}, PlotRangePadding -> None, DataRange -> {{0, numCols}, {0, numRows}}, Epilog -> {Hue[0, 0, 0], MapIndexed[Text[#1, #2 - .5] &, Transpose[lData], {2}]}] ]