使用 JSL 编辑颜色渐变比例大家好,
例如我有这个数据表

test = Graph Builder(
Variables( X( :X ), Y( :Y ), Color( :Value ) ),
Elements( Points( X, Y, Legend( 23 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
23,
Properties(
0,
{gradient(
{Scale Values( [-2 2] ), Label Format( "Fixed Dec", 15, 3 )}
)},
Item ID( "Value", 1 )
)
)}
)
)
);我运行上面的脚本来获取下面的图表,其颜色梯度为 +/-2 标准差。 如果数据集很大,这有助于不显示传单。
在下图中,我唯一要做的就是右键单击颜色渐变并将比例类型更改为线性(因为在线性比例中更容易思考)。 我正在努力编写这一步的脚本。

请注意,我不想要下面的图表,它只是调整梯度之前制作图表时的默认图表。

我得到的最接近的值如下,但它设置了从 -2 到 2 的线性缩放,这是我输入的标准偏差限制。
test << Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
3,
Properties(
0,
{gradient(
{ Scale Values[ ], Label Format( "Fixed Dec", 15, 4 ),
Scale Type( "Linear" )}
)},
Item ID( "Entry X Offset", 1 )
)
)}
)任何想法都非常感激! - 埃文
回复:使用 JSL 编辑颜色渐变比例这是一个示例,我动态确定其中一列的梯度。
dt = New Table( "Untitled", Add Rows( 4 ),
New Column( "X", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 2, 3, 4] ) ),
New Column( "Y", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [4, 1, 3, 2] ) ),
New Column( "Value", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 1, 2, 2] ) )
);
dtcol = column(dt, "Y");
one_min = col min(dtcol);
one_max = col max(dtcol);
one_avg = col mean(dtcol);
scale_matrix = matrix({one_min, one_avg, one_max});
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :X ), Y( :Y ), Color( :Value ) ),
Elements( Points( X, Y, Legend( 9 ) ) ),
SendToReport(
Dispatch( {}, "400", ScaleBox,
{Legend Model( 9,
Properties( 0,
{gradient( {Scale Values( scale_matrix )} )},
Item ID( "Value", 1 )
)
)}
)
)
);回复:使用 JSL 编辑颜色渐变比例练习的目的是了解 JSL GB 为定制秤生成的内容。一旦获得,您就可以通过编程方式确定每个数据集的缩放比例,并在运行时将其替换到 GB JSL 中。
回复:使用 JSL 编辑颜色渐变比例谢谢回复!
不过,我不想在图形生成器中进行任何手动工作。 我的(较大的)脚本的想法是自动制作许多图表,并为每个图表和数据集进行适当的缩放。 要查看模式,需要针对每列/数据集单独调整比例。 手动做的事情太多了。回复:使用 JSL 编辑颜色渐变比例在 GB 中处理图表并将比例设置为您想要的值。然后单击红色小三角并选择脚本 > 保存到脚本窗口。这是我稍微改变比例后得到的结果:
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :X ), Y( :Y ), Color( :Value ) ),
Elements( Points( X, Y, Legend( 9 ) ) ),
SendToReport(
Dispatch( {}, "400", ScaleBox,
{Legend Model( 9,
Properties( 0,
{gradient( {Scale Values( [2.2 2.6 3.2] )} )},
Item ID( "Value", 1 )
)
)}
)
)
);