The World Statistics Day celebration continues here in the Community. We all need reliable data for sound decision making. Do you have a data source that you trust most? Head over to Discussions to tell us about it.
Choose Language Hide Translation Bar
Highlighted
KC
KC
Level I

How to set legendbox position by passing variable?

Hi,

I want to set  LegendBox position by a list  as following jsl, but it is not work. how do I pass the "mylist " into position?

the list "mylist" will be  a dynamic result from other funciton , so I need to pass the variable  while setup graph builder  or update the graph builder after announcement.

I need the graph legendbox like the picture.  

 

 

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Show Control Panel( 0 ),
	Variables(
		X( :height ),
		Y( :weight ),
		Overlay( :sex )
	),
	Elements(
		Points( X, Y, Legend( 0 ) ),
		Smoother( X, Y, Legend( 1 ) )
	)
);

mylist={-1, -1, 1, 0};

Report( gb )[LegendBox( 1 )] << Position(mylist );

 position.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How to set legendbox position by passing variable?

The Position Message apparently does not support evaluation prior to its execution, therefore by using the Substitute() function you can force the evaluation.

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements(
		Points( X, Y, Legend( 0 ) ),
		Smoother( X, Y, Legend( 1 ) )
	)
);

mylist = {-1, -1, 1, 0};
Eval(
	Substitute(
			Expr(
				Report( gb )[LegendBox( 1 )] << Position( __myList__ )
			),
		Expr( __myList__ ), myList
	)
);
Jim

View solution in original post

1 REPLY 1
Highlighted
txnelson
Super User

Re: How to set legendbox position by passing variable?

The Position Message apparently does not support evaluation prior to its execution, therefore by using the Substitute() function you can force the evaluation.

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements(
		Points( X, Y, Legend( 0 ) ),
		Smoother( X, Y, Legend( 1 ) )
	)
);

mylist = {-1, -1, 1, 0};
Eval(
	Substitute(
			Expr(
				Report( gb )[LegendBox( 1 )] << Position( __myList__ )
			),
		Expr( __myList__ ), myList
	)
);
Jim

View solution in original post

Article Labels

    There are no labels assigned to this post.