@ClusteredMining fragte Heatmap erstellen – Wie definiere ich die Werte für jede Farbe im Farbverlauf?. Dies beantwortet die Frage nicht genau, aber vielleicht. Mit der GradientFunction und einer Farbliste ist es möglich, eine wirklich scharfe Grenze in einer dritten Farbe zu erhalten. Viele Variationen sind möglich, indem eine lange Liste von Farben angepasst wird, um die scharfen Grenzen zu erzeugen. Oder verschwommen, was schöner aussehen kann.
Die GradientFunction benötigt ein bisschen JSL, das die Frage beantworten kann " Was ist hier der Z-Wert? " Diese Funktion ist möglicherweise nicht ohne weiteres verfügbar, da sich die Daten in einer Tabelle befinden und nicht gut gerastert sind.
Bearbeiten: Sie sollten totalWidth wahrscheinlich eher größer als kleiner machen; Es steuert die Anzahl der Farben in der Farbliste, die die Genauigkeit der Kantenplatzierung steuert. Sie sollten wahrscheinlich auch den Rasterwert etwas größer machen. grid=100 und totalWidth=100 erscheint vernünftiger als 50 und 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>
Spielen Sie mit Grid, width und totalThick, um interessante Grafiken zu erhalten:
A thin sharply defined green region between red and blue.Ein dünner, scharf begrenzter grüner Bereich zwischen Rot und Blau.
Thicker, and still sharp.Dicker und trotzdem scharf.
Thicker, and blurry.Dicker und verschwommen.