@ClusteredMining問製作熱圖 - 如何定義漸變中每種顏色的值?. 這並不能完全回答問題,但也許。 使用 GradientFunction 和顏色列表,可以用第三種顏色獲得非常清晰的邊界。 通過定制一長串顏色來產生清晰的邊界,許多變化是可能的。 或模糊,這可能看起來更漂亮。
GradientFunction 需要一些 JSL 來回答這個問題“這裡的 Z 值是多少? “ 該功能可能不容易使用,因為數據在表中,並且沒有很好地網格化。
編輯:您應該使 totalWidth 變大而不是變小;它控制 colorList 中的顏色數量,後者控制邊緣放置的精度。 您可能也應該使網格值大一點。 grid=100 和 totalWidth=100 似乎比 50 和 10 更合理。
// these are in units of the Z value
range = {100, 400}; // the range of the color list; the formula a*b on the axis 10..20 makes these numbers
targetValue = 200; // happens to go through the corners for this example.
// grid: this determines how many points are evaluated by GradientFunction
grid = 50; // subdivisions, more looks smoother, is slower. typically 50 to 500. 667 may be a limit.
// how many colors in the colorList
thick = 0.050; // thickness of division line, can be 0. 50% is really fat (0.5)
totalWidth = 10; // make this smaller for a blurred edge, maybe 10 or 100 instead of 1000, which has a sharper edge
targetWidth = Round( thick * totalWidth );// making the green target about 10%, so kind of thick
otherwidth = totalWidth - targetWidth; // the ratios, below, divides this in parts
lowRatio = (targetValue - range[1]) / (range[2] - range[1]);// the red
highRatio = 1 - lowRatio;// the blue
// this list is a bunch of repeated reds, a few greens, and a
// bunch of blues. The greens are centered at the targetValue.
colorList = {};
Insert Into( colorList, As List( Repeat( RGB Color( .4, 0, 0 ), Round( otherwidth * lowRatio ) ) ) );
Insert Into( colorList, As List( Repeat( RGB Color( 0, .6, 0 ), targetWidth ) ) );
Insert Into( colorList, As List( Repeat( RGB Color( 0, 0, .4 ), Round( otherwidth * highRatio ) ) ) );
New Window( "target=" || Char( targetValue ),
g = Graph Box(
X Scale( 10, 20 ),
Y Scale( 10, 20 ),
framesize( 600, 400 ),
Gradient Function(
a * b,
a,
b,
Matrix( range ), // range to map the colors onto
Z Color( colorList ),
<<XGRID></XGRID>
嘗試使用 grid、width 和 totalThick 來獲得有趣的圖表:
A thin sharply defined green region between red and blue.A thin sharply defined green region between red and blue.A thin sharply defined green region between red and blue.A thin sharply defined green region between red and blue.A thin sharply defined green region between red and blue.紅色和藍色之間的薄而清晰的綠色區域。
Thicker, and still sharp.Thicker, and still sharp.Thicker, and still sharp.Thicker, and still sharp.Thicker, and still sharp.更厚,但仍然鋒利。
Thicker, and blurry.Thicker, and blurry.Thicker, and blurry.Thicker, and blurry.Thicker, and blurry.更厚,更模糊。