Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a list of lists containing spectral data, many thousands of points long. Each sublist contains 13 parts, and I need to plot them in 3D with a blend of RGB colors derived from the spectral data. So no problem until I get to coloring the plots. How can I use the list of 13 RGB triplets to create a blend to color each list plot?

Here are two datasets, one for a plot and one for the corresponding colors:

spectral = {{{48.76`, 63.49`, 72.76`, 76.78`, 78.02`, 78.96`, 79.73`, 
 80.41`, 81.21`, 81.83`, 82.39`, 83.03`, 83.56`, 84, 84.42`, 
 84.53`, 84.69`, 84.74`, 84.55`, 84.73`, 84.56`, 84.47`, 84.31`, 
 84.25`, 84.09`, 83.81`, 83.67`, 83.58`, 83.39`, 83.05`, 82.76`, 
 82.49`, 82.35`, 82.33`, 82.16`, 82.06`}, {42.08`, 57.42`, 67.24`,
  72.1`, 73.91`, 75.4`, 76.73`, 77.54`, 77.96`, 77.76`, 77.04`, 
 75.64`, 74.02`, 72.55`, 71.15`, 70.15`, 70.04`, 69.92`, 69.35`, 
 69.21`, 69.33`, 69.99`, 70.29`, 70.17`, 69.92`, 69.77`, 70.09`, 
 70.87`, 71.69`, 72.08`, 71.95`, 71.48`, 70.77`, 70.14`, 69.89`, 
 70.46`}, {42.03`, 56.78`, 66.37`, 70.92`, 72.63`, 74, 75.27`, 
 76.02`, 76.44`, 76.32`, 75.7`, 74.46`, 72.96`, 71.53`, 70.1`, 
 69.06`, 68.94`, 68.84`, 68.22`, 68.03`, 68.19`, 68.93`, 69.25`, 
 69.12`, 68.84`, 68.71`, 69.1`, 69.89`, 70.76`, 71.15`, 71.03`, 
 70.59`, 69.92`, 69.35`, 69.18`, 69.79`}, {39.03`, 53.63`, 63.5`, 
 68.37`, 70.26`, 71.8`, 73.19`, 73.93`, 74.24`, 73.92`, 72.91`, 
 71.04`, 68.78`, 66.59`, 64.33`, 62.75`, 62.43`, 62.19`, 61.25`, 
 60.78`, 61.04`, 62.1`, 62.66`, 62.45`, 62.06`, 61.91`, 62.52`, 
 63.73`, 65.08`, 65.81`, 65.78`, 65.28`, 64.36`, 63.57`, 63.44`, 
 64.42`}, {31.22`, 46.21`, 57.41`, 63.54`, 66.14`, 68.43`, 70.44`,
  71.39`, 71.38`, 70.37`, 68.2`, 64.36`, 59.76`, 55.23`, 50.36`, 
 46.94`, 45.98`, 45.24`, 43.14`, 41.64`, 42.14`, 44.33`, 45.51`, 
 45.06`, 44.19`, 44.02`, 45.32`, 47.88`, 50.81`, 52.62`, 52.78`, 
 52.06`, 50.5`, 49.01`, 49.26`, 51.58`}, {26.44`, 40.79`, 52.46`, 
 59, 61.93`, 64.58`, 66.88`, 67.92`, 67.76`, 66.38`, 63.6`, 
 58.72`, 52.92`, 47.21`, 41.06`, 36.78`, 35.48`, 34.49`, 31.86`, 
 29.83`, 30.43`, 33.14`, 34.6`, 34.03`, 32.93`, 32.74`, 34.34`, 
 37.51`, 41.2`, 43.52`, 43.79`, 42.96`, 41.05`, 39.21`, 39.61`, 
 42.46`}, {22.15`, 36.49`, 49.02`, 56.44`, 59.88`, 62.99`, 65.73`,
  66.93`, 66.45`, 64.57`, 60.92`, 54.74`, 47.62`, 40.78`, 33.58`, 
 28.71`, 27.21`, 26.08`, 23.15`, 20.89`, 21.54`, 24.47`, 26.08`, 
 25.45`, 24.24`, 24.08`, 25.86`, 29.41`, 33.6`, 36.35`, 36.72`, 
 35.8`, 33.66`, 31.63`, 32.2`, 35.6`}, {20.01`, 33.94`, 46.53`, 
 54.05`, 57.59`, 60.8`, 63.56`, 64.79`, 64.3`, 62.28`, 58.44`, 
 51.89`, 44.29`, 36.94`, 29.19`, 23.96`, 22.35`, 21.13`, 18.05`, 
 15.69`, 16.37`, 19.42`, 21.11`, 20.41`, 19.13`, 18.95`, 20.8`, 
 24.56`, 29.03`, 31.97`, 32.39`, 31.44`, 29.18`, 27.01`, 27.62`, 
 31.29`}, {18.84`, 32.74`, 45.29`, 52.81`, 56.47`, 59.72`, 62.63`,
  63.89`, 63.37`, 61.31`, 57.38`, 50.67`, 42.9`, 35.39`, 27.53`, 
 22.23`, 20.58`, 19.35`, 16.25`, 13.85`, 14.51`, 17.54`, 19.22`, 
 18.53`, 17.25`, 17.06`, 18.91`, 22.67`, 27.19`, 30.17`, 30.61`, 
 29.66`, 27.37`, 25.16`, 25.81`, 29.51`}, {18.4`, 32.15`, 45.16`, 
 53.05`, 56.88`, 60.39`, 63.55`, 64.83`, 64.16`, 61.86`, 57.5`, 
 50.25`, 42.03`, 34.26`, 26.29`, 21.02`, 19.39`, 18.18`, 15.16`, 
 12.84`, 13.47`, 16.4`, 18, 17.31`, 16.04`, 15.85`, 17.63`, 
 21.31`, 25.79`, 28.79`, 29.22`, 28.25`, 25.92`, 23.72`, 24.38`, 
 28.08`}, {17.83`, 31.87`, 44.91`, 53, 56.88`, 60.41`, 63.52`, 
 64.85`, 64.22`, 61.88`, 57.5`, 50.17`, 41.77`, 33.79`, 25.52`, 
 20.04`, 18.35`, 17.08`, 13.94`, 11.54`, 12.2`, 15.23`, 16.93`, 
 16.21`, 14.92`, 14.73`, 16.6`, 20.44`, 25.11`, 28.25`, 28.72`, 
 27.72`, 25.33`, 23.07`, 23.77`, 27.65`}, {17.54`, 31.72`, 45.01`,
  53.08`, 57, 60.61`, 63.78`, 65.09`, 64.41`, 62.05`, 57.6`, 
 50.13`, 41.53`, 33.28`, 24.72`, 19.04`, 17.29`, 15.99`, 12.78`, 
 10.36`, 11.05`, 14.16`, 15.9`, 15.16`, 13.82`, 13.64`, 15.58`, 
 19.54`, 24.4`, 27.63`, 28.12`, 27.11`, 24.64`, 22.28`, 23.06`, 
 27.08`}, {17.39`, 31.68`, 45.1`, 53.25`, 57.15`, 60.74`, 63.93`, 
 65.22`, 64.55`, 62.22`, 57.77`, 50.24`, 41.55`, 33.19`, 24.5`, 
 18.73`, 16.96`, 15.64`, 12.41`, 10, 10.71`, 13.83`, 15.58`, 
 14.83`, 13.47`, 13.31`, 15.26`, 19.27`, 24.16`, 27.44`, 27.9`, 
 26.86`, 24.37`, 22, 22.75`, 26.82`}}};  
color={{{0.73, 0.73, 0.7}, {0.63, 0.64, 0.68}, {0.62, 0.63, 0.67}, {0.57, 0.59, 0.66}, {0.44, 0.48, 0.65}, {0.36, 0.41, 0.63}, {0.3, 0.35,0.62}, {0.26, 0.32, 0.61}, 
{0.25, 0.31, 0.6}, {0.24, 0.3,0.61}, {0.23, 0.29, 0.61}, {0.22, 0.28, 0.61}, {0.22, 0.28, 0.61}}}; 

Using ListPlot3D for the plots, How can I plot these colors as blends over ListPlot3d?

share|improve this question
    
Is this what you were expecting? –  rm -rf Sep 16 '13 at 17:26
    
I'm having trouble understanding this. Could you please try to give an example or describe the output in a different way? –  Mr.Wizard Sep 16 '13 at 17:39
    
@rm-rf Almost! It appears the colors need rotating on the plot by 90 degrees, but yes this is very close!! Thanks –  R Hall Sep 16 '13 at 17:42
    
@Mr.Wizard rm-rf has a close example that will help show what I'm attempting to do. thanks! –  R Hall Sep 16 '13 at 17:48
    
Okay, I'll let rm -rf answer this one then. –  Mr.Wizard Sep 16 '13 at 17:50
add comment

1 Answer

up vote 3 down vote accepted

You can use Blend to blend the colors and input the appropriate coordinate to the ColorFunction to get the coloring you desire.

With[{cf = Blend[RGBColor @@@ First@color, #] &},
    ListPlot3D[spectral, ColorFunction -> Function[{x, y, z}, cf[y]]]]

For each of x, y and z as the input argument to cf, the following are the outputs:

share|improve this answer
    
sweet solution, thanks very much! –  R Hall Sep 16 '13 at 18:42
    
How can this be extended using Table to apply over multiple chunks for the list? –  R Hall Sep 16 '13 at 19:35
    
@RHall I don't understand what you mean by multiple chunks –  rm -rf Sep 16 '13 at 19:47
    
this data is from one of the sublists for a multi thousand list of lists. How can I map this solution over a list of lists? Thanks –  R Hall Sep 16 '13 at 19:54
    
@RHall Are all those lists to be plotted in the same plot? If you you could try plotting separately and using Show to combine them... –  rm -rf Sep 16 '13 at 19:59
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.