@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.红色和蓝色之间的薄而清晰的绿色区域。
Thicker, and still sharp.更厚,仍然锋利。
Thicker, and blurry.更厚,更模糊。