cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to add box plots to points when supplied Y variables as list to graph builder?

The following example script from an earlier thread (solved, thanks to @jthi) of mine allow me to plot Y variables as points when Y variables are supplied from a list.

I want to add Box Plots in addition to Points in my chart. How to add box plots in the script below?

Names Default To Here(1);
dt = Open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
variables_expr = Expr(Variables(X(:height)));
For Each({y_col}, y_values,
	temp_expr = Expr(Y());
	Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
	Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
	Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
	Eval(EvalExpr(
		Insert Into(gb_expr,
			Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
		)
	));
);
Show(Name Expr(gb_expr));
Eval(gb_expr); 

 

When it's too good to be true, it's neither
14 REPLIES 14
Neo
Neo
Level VI

Re: How to add box plots to points when supplied Y variables as list to graph builder?

@jthi Thanks. Is there a way to change the markers when the Points are plotted first rather than getting a handle to the legend server later and then changing the markers for each Y variable?

When it's too good to be true, it's neither
jthi
Super User

Re: How to add box plots to points when supplied Y variables as list to graph builder?

Is there a reason why they couldn't be changed after?

 

You could use SendToReport and build the Legend model inside Dispatch part with similar ideas as other parts in your script have been built.

-Jarmo
Neo
Neo
Level VI

Re: How to add box plots to points when supplied Y variables as list to graph builder?

@jthi Sure things could be changed after. Changing markers while the points are being plotted seemed like a simpler route to me.

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: How to add box plots to points when supplied Y variables as list to graph builder?

@jthi @txnelson In the main script below, I have added Local Data Filter () under Eval() which works as intended

Eval( gb_expr <<Local Data Filter( Add Filter( columns( :SITE ), Where( :SITE == {2, 3, 4} ) ) ) );

but if I add add the script for updating the markers the chart gets plotted twice!

 

Eval(
	server = gb_expr << Get Legend Server;
	For Each( {item}, server << Get Legend Items, item << Set Properties( {Marker( "Circle" )} ) );
);

 

 

Names Default To Here( 1 );
Clear Log();

dt = Open( "$sample_data\Semiconductor Capability.jmp" );

y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};

variables_expr = Expr(
	Variables( X( :lot_id ) )
);
For Each( {y_col}, y_values,
	temp_expr = Expr( Y() );
	Insert Into( temp_expr, Name Expr( As Column( dt, y_col ) ) );
	Insert Into( variables_expr, Name Expr( temp_expr ) );
);
gb_expr = Expr(
	Graph Builder( Show Control Panel( 0 ) )
);
Insert Into( gb_expr, Name Expr( variables_expr ) );
For Each( {y_col, idx}, y_values,
	Eval(
		Eval Expr(
			Insert Into(
				gb_expr,
				Name Expr(
					Elements(
						Position( 1, Expr( idx ) ),
						Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
						Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
					)
				)
			)
		)
	)
);

//Show( Name Expr( gb_expr ) );
Eval( gb_expr <<Local Data Filter( Add Filter( columns( :SITE ), Where( :SITE == {2, 3, 4} ) ) ) );

Eval(
	server = gb_expr << Get Legend Server;
	For Each( {item}, server << Get Legend Items, item << Set Properties( {Marker( "Circle" )} ) );
);

The second chart is with the updated markers.

How to plot a single chart with the updated markers together the local data filter?

I guess, I am unable to place the the last piece for marker change correctly where I request some help. 

 

When it's too good to be true, it's neither
jthi
Super User

Re: How to add box plots to points when supplied Y variables as list to graph builder?

You don't want to run gb_expr twice. You want to get the reference you get from gb_expr and send those messages to it

gb = Eval( gb_expr );
gb << Local data Filter(...)
server = gb << get legend server;
-Jarmo