简体   繁体   中英

ILLinePlot color depending on Y-value?

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();
// 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM