cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Wei1
Level II

How do I use jsl add X variable to graphbuilder

Dear all:

I want to create a parallel graph
The X-axis is part of the column in the table
How to create using jsl

 

I also try add variable() but cannot work

 

thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How do I use jsl add X variable to graphbuilder

<< Add Variable should work but some cases can be more complicated

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(528, 448),
	Show Control Panel(0),
	Variables(X(:weight), X(:height, Position(1))),
	Elements(Parallel(X(1), X(2), Legend(9)))
);

wait(1); // for demo purposes

gb << Add Variable({:age, Role("X"), Position(1)});
-Jarmo

View solution in original post

jthi
Super User

Re: How do I use jsl add X variable to graphbuilder

If you build the parallel plot by hand and check the script

Graph Builder(
	Size(490, 448),
	Show Control Panel(0),
	Variables(
		X(:X__1),
		X(:X__2, Position(1)),
		X(:X__3, Position(1)),
		X(:X__4, Position(1)),
		X(:X__5, Position(1))
	),
	Elements(Parallel(X(1), X(2), X(3), X(4), X(5), Legend(18)))
)

and then compare it to your script (build it and then get script from red triangle menu)

Graph Builder(
	Size(1854, 917),
	Show Control Panel(0),
	Variables(
		X(:X__1),
		X(:X__2, Position(1)),
		X(:X__3, Position(1)),
		X(:X__4, Position(1)),
		X(:X__5, Position(1))
	),
	Elements(
		Points(X(1), X(2), X(3), X(4), X(5), Legend(5)),
		Parallel(Legend(4), Combine Sets(1))
	)
)

There are few big differences: you still have points left and you only haven't defined X() in your script.

 

If this is what you wish to do, I would suggest building the graph builder expression and not using << Add Variable and << Add Element as it can be easier

Names Default To Here(1);

dt = Current Data Table();

colnames = dt << get column names("character");
Remove From(colnames, N Items(colnames));
Remove From(colnames, 1);

variables_expr = Expr(Variables(X(:X__1)));
parallel_expr = Expr(Parallel(X(1)));

For Each({colname, idx}, colnames,
	xpart = EvalExpr(X(Expr(NameExpr(AsColumn(dt, colname))), Position(1)));
	Insert Into(variables_expr, Name Expr(xpart));
	
	Eval(EvalExpr(
		Insert Into(parallel_expr, Name Expr(X(Expr(idx + 1))));
	));
);

Insert Into(parallel_expr, Name Expr(Legend(18)));
elements_expr = Expr(Elements());
InsertInto(elements_expr, NameExpr(parallel_expr));


gb = Eval(Substitute(
		Expr(dt << Graph Builder(
			Size(1854, 917),
			Show control Panel(0),
			_variables_,
			_elements_,
			Color(:color),
			Size(:Amt)
	)),
	Expr(_variables_), Name Expr(variables_expr),
	Expr(_elements_), Name Expr(elements_expr)
));

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How do I use jsl add X variable to graphbuilder

<< Add Variable should work but some cases can be more complicated

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(528, 448),
	Show Control Panel(0),
	Variables(X(:weight), X(:height, Position(1))),
	Elements(Parallel(X(1), X(2), Legend(9)))
);

wait(1); // for demo purposes

gb << Add Variable({:age, Role("X"), Position(1)});
-Jarmo
Wei1
Level II

Re: How do I use jsl add X variable to graphbuilder

Thanks,

 

Have other question,

 

Now I can use Add Variable to add X variables to graph builder,

but cannot change to parallel graph for add X variable (auto) by use Add Element

 

Please refer to the attachment

 

thanks

Names Default To Here(1);

dt=Current Data Table();

colnames=dt<< get column names( "character" );
remove from(colnames,nitems(colnames));
remove from(colnames,1);

variables_expr = Expr(Variables(X(:X__1)));

gb = dt << Graph Builder(
Size( 1854, 917 ),
 Show control Panel(0),
 Variables(X(:X__1)),
 Color( :color ),				
		Size( :Amt )
);

gb << inval;

For Each({x_col, idx}, colnames,
 Eval(EvalExpr(
  gb << Add Variable({Expr(Name Expr(As Column(dt, x_col))), Role("X"),position(1)})
 ));


);

// question
gb << Add Element( 1, 1, {Type( "Parallel" ),Legend( 4 ),Combine Sets( 1 )} );


gb << Update window;
jthi
Super User

Re: How do I use jsl add X variable to graphbuilder

If you build the parallel plot by hand and check the script

Graph Builder(
	Size(490, 448),
	Show Control Panel(0),
	Variables(
		X(:X__1),
		X(:X__2, Position(1)),
		X(:X__3, Position(1)),
		X(:X__4, Position(1)),
		X(:X__5, Position(1))
	),
	Elements(Parallel(X(1), X(2), X(3), X(4), X(5), Legend(18)))
)

and then compare it to your script (build it and then get script from red triangle menu)

Graph Builder(
	Size(1854, 917),
	Show Control Panel(0),
	Variables(
		X(:X__1),
		X(:X__2, Position(1)),
		X(:X__3, Position(1)),
		X(:X__4, Position(1)),
		X(:X__5, Position(1))
	),
	Elements(
		Points(X(1), X(2), X(3), X(4), X(5), Legend(5)),
		Parallel(Legend(4), Combine Sets(1))
	)
)

There are few big differences: you still have points left and you only haven't defined X() in your script.

 

If this is what you wish to do, I would suggest building the graph builder expression and not using << Add Variable and << Add Element as it can be easier

Names Default To Here(1);

dt = Current Data Table();

colnames = dt << get column names("character");
Remove From(colnames, N Items(colnames));
Remove From(colnames, 1);

variables_expr = Expr(Variables(X(:X__1)));
parallel_expr = Expr(Parallel(X(1)));

For Each({colname, idx}, colnames,
	xpart = EvalExpr(X(Expr(NameExpr(AsColumn(dt, colname))), Position(1)));
	Insert Into(variables_expr, Name Expr(xpart));
	
	Eval(EvalExpr(
		Insert Into(parallel_expr, Name Expr(X(Expr(idx + 1))));
	));
);

Insert Into(parallel_expr, Name Expr(Legend(18)));
elements_expr = Expr(Elements());
InsertInto(elements_expr, NameExpr(parallel_expr));


gb = Eval(Substitute(
		Expr(dt << Graph Builder(
			Size(1854, 917),
			Show control Panel(0),
			_variables_,
			_elements_,
			Color(:color),
			Size(:Amt)
	)),
	Expr(_variables_), Name Expr(variables_expr),
	Expr(_elements_), Name Expr(elements_expr)
));

-Jarmo