將可用顏色對應到回應:您可以使用 JMP 中內建的顏色主題,也可以使用 JMP 中的工具建立自訂映射。 您必須編寫 JSL 才能使用自訂映射;它不會成為一個主題。
使用內建主題:HeatColor 函數將 0 到 1 之間的數字對應為顏色。 本範例使用「jet」和「spectral」兩個主題,並製作了下圖。
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 日的格式和程式碼修復,但舊部落格格式的轉換後無法存活。