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

How do I add ref lines to multiple Y in scatterplot Matrix?

I have a question about adding ref lines to multiple Y in Scatterplot Matrix.

 

I succeed to get ref line values.

but, I don't know how to add.

 

I want to know add ScaleBox to every "Y"s.

 

For exaple, 

 

//sel_colnames = {"SPK_VOS_TrimCode_Dec", "SPK_RCV_VOS_TrimCode_Dec", "SPK_RCV_VOS_Post_0p5W"};

 

upper_limit = {10, 1, 15, 0.75};
lower_limit = {-10, 0.5, -15, -0.75};

 

I want to add upper_limit & lower_limit to the below chart.

Also, I want to adjust Y axis scales for each "Y"s.

 

NagneTE1_0-1717752392379.png

 

//JSL for multiple "Y"s - please give me an advice on it.

 

Names Default To Here(1);


dt adress = pick file({"All Files|*"});
dt = Open(
	dt adress,
	columns(
	),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Comma, CSV( 1 ) ),
		Strip Quotes( 0 ),
		Use Apostrophe as Quotation Mark( 0 ),
		Use Regional Settings( 0 ),
		Scan Whole File( 1 ),
		Treat empty columns as numeric( 0 ),
		CompressNumericColumns( 0 ),
		CompressCharacterColumns( 0 ),
		CompressAllowListCheck( 0 ),
		Labels( 0 ),
		Column Names Start( 1 ),
		Data Starts( 47 ),
		Lines To Read( "All" ),
		Year Rule( "20xx" )
	)
);


//Delete unnecessary columns
dt=Current Data Table ();
dt << Delete Columns( :"Column 2"n, :"Column 3"n, :"Column 4"n, :"Column 5"n);
dt << delete row( 6 );


// Split dt -> dt(value of test item) & dt_item(upper&lower limit of test item)
dt << select rows({1,2,3,4,5}) ;
dt_item = subset( dt );
dt << delete rows( {2,3,4,5} );


// Replace column names with Test Name (*dt)
For( c = 1, c < N Col( dt ), c ++,
 Column( dt, c ) << Set Name( Column( dt, c )[1] );
);
// Replace column names with Test Name (*dt_item)
For( c = 1, c < N Col( dt_item ), c ++,
 Column( dt_item, c ) << Set Name( Column( dt_item, c )[1] );
);

dt << delete rows( {1} );
dt_item << delete rows( {1} );


//Change Data Type to Numeric&Continuous (*dt)
colList = dt << get column names(charater);

For(i=1,i<=n items(colList), i++,
column(dt, colList[i]) << Data Type( Numeric ) << Set Modeling Type( Continuous );
);
//Change Data Type to Numeric&Continuous (*dt_item)
colList = dt_item << get column names(charater);

For(i=1,i<=n items(colList), i++,
column(dt_item, colList[i]) << Data Type( Numeric ) << Set Modeling Type( Continuous );
);


///Data processing done.



//Select Test Item for Scatterplot Matrix
colDlg = Column Dialog(
	Title( "Test Item Selct" ),
	ycol = Col List( "Test Item", Min Col( 1 ), Max Col(15) ), //
);


//Read Test Item's Test Number, Upper & Lower Limit 
n = N Items( colDlg["ycol"] );

dt_item << Select Columns( colDlg["ycol"]);

sel_colnames = dt_item << Get Selected Columns(string); 
show(sel_colnames);


//Read Test Item's Test Number, Upper & Lower Limit
rowNum = 1;
col = Column( dt_item(), colDlg["ycol"]);
test_no = col[ rowNum ];
//Read UL 
rowNum = 3;
upper_limit = col[ rowNum ];
//Read LL
rowNum = 2;
lower_limit = col[ rowNum ];


//Read Test Item's Test Number, Upper & Lower Limit
test_no = {};
upper_limit = {};
lower_limit = {};

for(cnt=1, cnt <= n, cnt++,
col = Column( dt_item(), sel_colnames[cnt]);
show (col);
rowNum = 1;
test_no[cnt] = col[ rowNum ];
//Read UL 
rowNum = 3;
upper_limit[cnt] = col[ rowNum ];
//Read LL
rowNum = 2;
lower_limit[cnt] = col[ rowNum ];
);
show(test_no);	show(upper_limit);	show(lower_limit);


//Scatterplot Matrix
stm = dt << Scatterplot Matrix(Y(colDlg["ycol"]), X( :Test Name),
	Fit Line( 0 ),
	SendToReport(
		Dispatch(
			{},
			"1100",
		),
		Dispatch( {}, "Test Name", TextEditBox, {Set Text( "Site #" )}),
		Dispatch( {}, "Scatterplot Matrix Plot", FrameBox, {Frame Size( 500, 200 )} ),
	)
);

//Close Data Tables without the report.
stm << Journal;

close(dt,"nosave");
close(dt_item,"nosave");

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How do I add ref lines to multiple Y in scatterplot Matrix?

At least you will have to abs to abs[x] as currently you are setting all the limits to all axisboxes

Names Default To Here(1); 

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

cols = {"height", "weight"};

lsls = {55, 80};
usls = {70, 160};

spm = dt << Scatterplot Matrix(
	Y(Eval(cols)),
	X(:age),
	Fit Line(0)
);

abs = Report(spm) << XPath("//AxisBox");
Remove From(abs, N Items(abs)); // Drop x-axis

For (x=1, x <= N Items(abs), x++,
	Eval(EvalExpr(
		abs[x] << Add Ref Line(Expr(lsls[x]), "Dashed", blue, Expr(Char(lsls[x])), 1);
		abs[x] << Add Ref Line(Expr(usls[x]), "Dashed", blue, Expr(Char(usls[x])), 1);
	))
);
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: How do I add ref lines to multiple Y in scatterplot Matrix?

Here is one simplified example

Names Default To Here(1); 

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

cols = {"height", "weight"};

lsls = {55, 80};
usls = {70, 160};

spm = dt << Scatterplot Matrix(
	Y(Eval(cols)),
	X(:age),
	Fit Line(0)
);

abs = Report(spm) << XPath("//AxisBox");
Remove From(abs, N Items(abs)); // Drop x-axis

For Each({ab, idx}, abs,
	Eval(EvalExpr(
		ab << Add Ref Line(Expr(lsls[idx]), "Dashed", blue, "LSL", 1);
		ab << Add Ref Line(Expr(usls[idx]), "Dashed", blue, "USL", 1);
	))
);

Using Associative Array to store limits might make the code a bit cleaner

-Jarmo
NagneTE1
Level II

Re: How do I add ref lines to multiple Y in scatterplot Matrix?

Thank you for your reply.

The example doesn't work in my JMP version 15.

 

How can I replace "For Each" syntax? 

Sorry. I don't know how "For Each" works.

 

-------------------------

 

I just replaced For Each syntax with for syntax.

Almost works, but Every 'Y' has the same ref line. (*limit[1] value..)

 

How can I fix it?

 

For Each -> For

abs = Report(stm) << XPath("//AxisBox"); //Display Option. 
Remove From(abs, N Items(abs)); // Drop x-axis

//Show (N Items(abs));

For (x=1, x <= N Items(abs), x++ ,
	Eval(EvalExpr(
		abs << Add Ref Line(Expr(lower_limit[x]), "Dashed", blue, "LSL", 1);
		abs << Add Ref Line(Expr(upper_limit[x]), "Dashed", blue, "USL", 1);
	))
);

*result

NagneTE1_1-1717985229912.png

 

Thanks

 

 

jthi
Super User

Re: How do I add ref lines to multiple Y in scatterplot Matrix?

At least you will have to abs to abs[x] as currently you are setting all the limits to all axisboxes

Names Default To Here(1); 

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

cols = {"height", "weight"};

lsls = {55, 80};
usls = {70, 160};

spm = dt << Scatterplot Matrix(
	Y(Eval(cols)),
	X(:age),
	Fit Line(0)
);

abs = Report(spm) << XPath("//AxisBox");
Remove From(abs, N Items(abs)); // Drop x-axis

For (x=1, x <= N Items(abs), x++,
	Eval(EvalExpr(
		abs[x] << Add Ref Line(Expr(lsls[x]), "Dashed", blue, Expr(Char(lsls[x])), 1);
		abs[x] << Add Ref Line(Expr(usls[x]), "Dashed", blue, Expr(Char(usls[x])), 1);
	))
);
-Jarmo
NagneTE1
Level II

Re: How do I add ref lines to multiple Y in scatterplot Matrix?

Thanks a lot!!