cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

Can a number in an array be replaced by a variable?

For example, in the drawing of JSL the following values

Color Levels([-7.28 -1.99 3.3 8.59 13.88]);

How can I write code in this form?

x1=-7.28;
x2=13.88;
Color Levels([x1 -1.99 3.3 8.59 x2]);

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
ErraticAttack
Level VI

Re: Can a number in an array be replaced by a variable?

Matrices can be a little tricky, but here is what I do in that situation:

 

x1 = -7.28;
x2 = 13.88;
Color Levels( (x1 |/ [-1.99 3.3 8.59]` |/ x2)` );

This uses the matrix join operator |/ then a few transposes to make it have the correct dimensions

Jordan

View solution in original post

jules
Community Manager Community Manager

Re: Can a number in an array be replaced by a variable?

If you construct your matrix using the Matrix() function you can call in variables as arguments directly. For example:

x1=-7.28;
x2=13.88;
mat = matrix({x1,-1.99, 3.3, 8.59, x2})`
//notice the need to transpose; the syntax is easier to construct this way

Here's a more complete building the entire matrix dynamically: 

Names Default To Here( 1 );

x1=100000; x2=1000000; x3=10000000;

dt = Open( "$SAMPLE_DATA/PopAgeGroup.jmp" );
obj = dt << Bubble Plot(
	X( :"Portion 0-19"n ),
	Y( :"Portion60+"n ),
	Sizes( :Pop ),
	ID( :Country ),
	Coloring( :Pop )
);
obj << Color Levels( matrix({x1,x2,x3})` );

I hope this helps!

@jules 

View solution in original post

3 REPLIES 3
lala
Level IX

回复: Can a number in an array be replaced by a variable?

OK

2022-12-10_15-58-59.png

ErraticAttack
Level VI

Re: Can a number in an array be replaced by a variable?

Matrices can be a little tricky, but here is what I do in that situation:

 

x1 = -7.28;
x2 = 13.88;
Color Levels( (x1 |/ [-1.99 3.3 8.59]` |/ x2)` );

This uses the matrix join operator |/ then a few transposes to make it have the correct dimensions

Jordan
jules
Community Manager Community Manager

Re: Can a number in an array be replaced by a variable?

If you construct your matrix using the Matrix() function you can call in variables as arguments directly. For example:

x1=-7.28;
x2=13.88;
mat = matrix({x1,-1.99, 3.3, 8.59, x2})`
//notice the need to transpose; the syntax is easier to construct this way

Here's a more complete building the entire matrix dynamically: 

Names Default To Here( 1 );

x1=100000; x2=1000000; x3=10000000;

dt = Open( "$SAMPLE_DATA/PopAgeGroup.jmp" );
obj = dt << Bubble Plot(
	X( :"Portion 0-19"n ),
	Y( :"Portion60+"n ),
	Sizes( :Pop ),
	ID( :Country ),
	Coloring( :Pop )
);
obj << Color Levels( matrix({x1,x2,x3})` );

I hope this helps!

@jules 

Recommended Articles