The JSL code below attempts to use the add Element method to display a Contour plot on the graph on the right side. However, because add Element is an Add Element operation, it cannot remove or replace the original Points format on the right-side graph, resulting in the generated image being different from the figure below. The original Points remain along with the added Contour. Since the X-axis can only be appended afterwards, is there any way to remove the original Points format while still using add Element?
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} );

You can remove the point element
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});
or you could build the graph builder expression to take this into account
1. You have already added points to your graph even though you do not have x-axis -> you might end up with more Points graphs than you think.
Run graph builder script -> copy script
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)))
);
Run << Add Variable -> Copy script
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)))
);
Run << Add Variable -> Copy script
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>
<P> </P>
<P> </P>
<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)))
);
Run << Remove Element -> copy script
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))
);
and so on.
You can give yourself much better chance of success if you use as complete graph builder as possible
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. You can adjust the x-axis with a script (the axis are different as contour plot needs more space than 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 << 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);