将可用颜色映射到响应:您可以使用 JMP 中内置的颜色主题,也可以使用 JMP 中的工具构建自定义映射。 您必须编写 JSL 才能使用自定义映射;它不会是一个主题。
使用内置主题:HeatColor 函数将 0 和 1 之间的数字映射为颜色。 本例使用“喷射”和“光谱”两个主题,制作如下图。
New Window( "Example", Graph Box( Y Scale( -0.6, 1.6 ), X Scale( -5, 105 ),
framesize( 700, 300 ), Marker Size( 6 ), suppressAxes,
For( x = 0, x <= 100, x += .0625,
Pen Color( Heat Color( x / 100, "jet" ) );
Line( {x, 0}, {x, .5} );
Pen Color( Heat Color( x / 100, "spectral" ) );
Line( {x, .6}, {x, 1.1} );
);
Text Color( "black" );
Text( right justified, {98, .1}, "jet color interpolation" ); // use right
Text( right justified, {98, .7}, "spectral color interpolation" ); // justification
)
);

更多关于 HeatColor:图形功能
内置主题很好,友好且易于使用,但您可能需要一些不同的东西。 以下示例演示了 JMP 中用于插值的两个不同函数:Interpolate 和 SplineEval。 两者都有优点和缺点。 首先,图片的代码:
smooth = 300; // bigger numbers make a stiffer spline
xRange = 0 :: 100; // graph plotted over this range
// greenX,greenY define 5 "control" points for the color; the Y value is the green in RGB
greenX = [0 3 5 7 10] ^ 2; // unevenly spaced points in X: [0 9 25 49 100]
greenY = [0.1 0.4 0.9 0.4 0.1]; // uneven in Y too
// greenCoef is computed once, used a lot in the evaluator
greenCoef = Spline Coef( greenX, greenY, smooth ); // make the coefficients once
greenSpline = Spline Eval( xRange, greenCoef ); //use them here, and below
// greenSpline as a matrix of Ys for each X in the xRange argument
// or...linear piece-wise interpolation (the first argument must be a scalar at this time)
greenLinear = J( 1, N Cols( xRange ), 0 ); // unlike spline, for now at least,
For( i = 1, i <= N Cols( xRange ), i++, // interpolate generates one answer per call
greenLinear[i] = Interpolate( xRange[i], greenX, greenY ); // edgy version of smooth spline
);
// graph the spline and linear colors
New Window( "Example", Graph Box( Y Scale( -0.6, 1.6 ), X Scale( -5, 105 ),
framesize( 700, 300 ), Marker Size( 6 ), suppressAxes,
Pen Color( "green" ); Pen Size( 5 );
Line( xRange, greenSpline ); // draw the smooth spline, thick, green
Pen Color( "blue" ); Pen Size( 3 );
Line( xRange, greenLinear ); // draw the pointy linear interpolation, thinner, blue
// next, draw the large black round marker dots...
Marker( Combine States( Color State( "black" ), Marker State( 12 ) ), greenX, greenY );
// draw the horizontal color bars, above and below the graph
Pen Size(1);
For( x = 0, x <= 100, x += .0625, // generate enough short vertical lines to make a
// solid patch of color. set the color of each line by spline...
Pen Color( RGB Color( 0, Spline Eval( x, greenCoef ), .5 ) ); // use the coefficients again
Line( {x, 1.1}, {x, 1.5} ); // color bar above the graph is for spline
Pen Color( RGB Color( 0, Interpolate( x, greenX, greenY ), .5 ) ); // set color by linear
Line( {x, -.1}, {x, -.5} ); // color bar below graph is linear interpolation
);
// label the color bars. Should work OK with reasonable sized fonts...
Text Color( "white" ); // lands on top of the dark part of the color bar
Text( right justified, {98, -.4}, "linear color interpolation" ); // use right
Text( right justified, {98, 1.2}, "spline color interpolation" ); // justification
)
);

图为绿色样条曲线和蓝色线性插值曲线。 两条曲线都是为 5 个黑色控制点构建的。 图片顶部显示了通过将绿色分量设置为绿色样条曲线值制成的颜色条。 图片底部显示了类似的颜色条,但绿色分量来自线性插值。
您可能已经被底栏中过亮的地方分心了。 别担心,它不是真的存在,它与马赫乐队 - 维基百科,免费的百科全书. 但这是您可能更喜欢样条插值的原因。 样条插值有不同的问题,主要是围绕下冲和过冲。 顶部栏永远不会像底部栏那样亮绿色。在这种情况下很难说,但它也低于最终点。 上面 JSL 中的第一行,smooth=300,是设置样条的刚度/张力。 您必须选择适合您的应用程序的值。
在 HeatColor 示例中,您可以转换 0..1 参数(可能使用 SQRT)以拉伸颜色。 使用样条曲线和插值,您可以通过根据需要放入尽可能多的控制点来拉伸/挤压颜色空间(如本示例所做的那样)。 您也可以添加红色和蓝色通道,并为它们提供自己的配置文件。
附加的文件与帖子中的代码相同。
更多关于 SplineEval:补充说明
更多关于插值:条件函数
2017 年 1 月 4 日更新了从旧博客格式转换后无法幸存的格式化和代码修复。