1

It is common pratice to let 3D surfaces have different colors in different areas depending on the Z-value at the particular point. In order to achieve that I simply call the mehtod UpdateColormapped on my ILSurface-object. I would like to do the same thing with a 2-dimensional ILLinePlot inside a 3-dimensional plot cube, so that the color varies with the Y-value of the line plot. I asked directly on the ILNumerics web site how to do this and got the following answer:

"Sure, it is simple to do:

1) set the Line.Colors ('Colors' not 'Color'!) property of ILLinePlot to the color needed.

2) Set the solid Color = null ('Color' not 'Colors'!) and

3) Call Line.Configure() at the end to push the colors to the renderer.

The ILColormap.Map() function could be of help in order to create colors for all line vertices according to some colormap. Alternatively you can create the colors array manually. You may open a new thread on stackoverflow, if you have problems getting it work."

Unfortunately I don't understand what they mean. Could some please help me complete this code snippet according to the instruction above:

ILLinePlot my2DlinePlot = new ILLinePlot();
my2DlinePlot.Line.Colors = ?
my2DlinePlot.Line.Color = null;
my2DlinePlot.Line.Configure();
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
arnold_w
  • 59
  • 9

1 Answers1

2
// your data for plotting
ILArray<float> A = new float[]{0,3,2,-1,4,2}; // replace with your data 

ILLinePlot my2DlinePlot = new ILLinePlot(A);
// map the Y values in A to colors using a colormap
var cm = new ILColormap(Colormaps.Jet); 
my2DlinePlot.Line.Colors = cm.Map(A).T;  // colors data must be 3xn or 4xn
my2DlinePlot.Line.Color = null;
my2DlinePlot.Line.Configure();

Online docu for Map(): http://ilnumerics.net/apidoc/?topic=html/M_ILNumerics_Drawing_Plotting_ILColormap_Map.htm

user492238
  • 4,094
  • 1
  • 20
  • 26
  • Thanks, I can now see it changing colors, but it's not using the same colormap as my 3D surfce uses (by default). What is the default colormap called (the one that is turquoise in the lower area, then becomes green, then yellow and the maximum values are red)? – arnold_w Jul 22 '14 at 14:44
  • 1
    I think the default is 'ILNumerics' ;) http://ilnumerics.net/apidoc/html/M_ILNumerics_Drawing_Plotting_ILSurface__ctor.htm – Haymo Kutschbach Jul 23 '14 at 21:32