下面的 JSL 代码尝试使用 add Element 方法在右侧图表上显示轮廓图。但是,由于 add Element 本身就是一个 Add Element 操作,它无法移除或替换右侧图表上原始的 Points 格式,导致生成的图像与下图不同。原始 Points 会与添加的轮廓图一起保留。由于 X 轴只能在之后添加,那么有没有办法在仍然使用 add Element 的同时移除原始的 Points 格式呢?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 488, 352 ),
Show Control Panel( 0 ),
Fit to Window( "Off" ),
Variables( Y( :weight ), Overlay( :age ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 21 ) ), Points( X, Y, Legend( 23 ) ) ),
//Elements( Position( 2, 1 ), Contour( X, Y, Legend( 22 ) ) ),
);
gb << Add Variable( {:height, Role( "X" )} );
gb << Add Variable( {:Height, Role( "X" )} );
gb << Add Element( 1, 1, {Type( "Points" ), X, Y} );
gb << Add Element( 2, 1, {Type( "Contour" ), X, Y} );

您可以删除点元素
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(Y(:weight), Overlay(:age)),
Elements(Position(1, 1), Points(X, Y, Legend(21)), Points(X, Y, Legend(23))),
//Elements( Position( 2, 1 ), Contour( X, Y, Legend( 22 ) ) ),
);
gb << Add Variable({:height, Role("X")});
gb << Add Variable({:Height, Role("X")});
gb << Remove Element(2, 1, 1);
gb << Remove Element(2, 1, 1);
gb << Add Element(2, 1, {Type("Contour"), X, Y});
或者你可以构建图形生成器表达式来考虑到这一点
1. 即使您没有 x 轴,您也已经在图表中添加了点 -> 您最终可能会得到比您想象的更多的点图。
运行图形构建器脚本->复制脚本
Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(Y(:weight), Overlay(:age)),
Elements(Points(Y, Legend(21)), Points(Y, Legend(23)))
);
运行<<添加变量->复制脚本
Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(X(:height), Y(:weight), Overlay(:age)),
Elements(Points(X, Y, Legend(21)), Points(X, Y, Legend(23)))
);
运行<<添加变量->复制脚本
Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(X(:height), X(:height), Y(:weight), Overlay(:age)),
Elements(Position(1, 1), Points(X, Y, Legend(21)), Points(X, Y, Legend(23))),
Elements(Position(2, 1), Points(X, Y, Legend(24)), Points(X, Y, Legend(25)))
);
</CODE>Run << Remove Element -> copy script</P>
<BR />
<BR />
<PRE><CODE class=" language-jsl">Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(X(:height), X(:height), Y(:weight), Overlay(:age)),
Elements(Position(1, 1), Points(X, Y, Legend(21)), Points(X, Y, Legend(23))),
Elements(Position(2, 1), Points(X, Y, Legend(25)))
);
运行<<删除元素->复制脚本
Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(X(:height), X(:height), Y(:weight), Overlay(:age)),
Elements(Position(1, 1), Points(X, Y, Legend(21)), Points(X, Y, Legend(23))),
Elements(Position(2, 1))
);
等等。
如果你使用尽可能完整的图表构建器,你将获得更大的成功机会
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(488, 393),
Show Control Panel(0),
Fit to Window("Off"),
Variables(X(:height), Y(:weight), Overlay(:age)),
Elements(Points(X, Y, Legend(2)))
);
gb << Add Variable({:Height, Role("X"), Position(2)});
gb << Remove Element(2, 1, 1);
gb << Add Element(2, 1, {Type("Contour"), X, Y});
2. 您可以使用脚本调整 x 轴(由于等高线图比点需要更多空间,因此轴有所不同)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(488, 352),
Show Control Panel(0),
Fit to Window("Off"),
Variables(Y(:weight), Overlay(:age)),
Elements(Position(1, 1), Points(X, Y, Legend(21)), Points(X, Y, Legend(23))),
//Elements( Position( 2, 1 ), Contour( X, Y, Legend( 22 ) ) ),
);
gb << Add Variable({:height, Role("X")});
gb << Add Variable({:Height, Role("X")});
gb << Remove Element(2, 1, 1);
gb << Remove Element(2, 1, 1);
gb << Add Element(2, 1, {Type("Contour"), X, Y});
min2 = Report(gb)[AxisBox(3)] << get min;
max2 = Report(gb)[AxisBox(3)] << get max;
Report(gb)[AxisBox(1)] << Min(min2) << Max(max2);