cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Aslam0424
Level II

Extract or return correlation values using density ellipse from a graph builder plots in JSL

Hello,

 

I am kind a new to JSL. I am plotting a graph of numerical vs categorical data using graph builder function in JMP and adding ellipse to see a correlation as well. I am using the scripts for my future plots but I want customize a bit by storing the correlation(pointed with red arrow in figure) values somewhere in a variable so that I can use it in some logical operations. For example if I want to plot graphs only which has correlation more than 0.45. Any JSL script, help or leads would be appreciated. Following I tried some but no success yet.

Thank you!

gb = dt << Graph Builder(
	Variables( X( :"A_column"n ), Y( :"B_column"n ) ),
	Elements(
		Points( X, Y, Legend( 3 ) ),
		Ellipse( X, Y, Legend( 4 ), Correlation( 1 ), Mean Point( 1 ) )
	),
	SendToReport(
		Dispatch( {"Ellipse"}, "", OutlineBox, {Close( 0 )} ),
		Dispatch( {"Pairwise Correlations"}, "", TableBox, {Sort By Column( 7, 1 )} )
	)
);
thing_report = gb << report;
Show Properties( thing_report );
corr = biv << Get Correlation Matrix;
Show( corr );

Aslam0424_1-1655418197206.png

Store the correlation pointed in with the red arrow.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

I'm not sure if you should be checking for correlation like this between Continuous and Nominal columns, but... you can export the correlation from graph builder with something like this (not sure how easily this will break):

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(535, 457),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight)),
	Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1)))
);

ts = Report(gb)[Frame Box(1)] << Find Seg("TextSeg");
corr = ts << get text;

How I got there:

1. Created graph builder and opened Customize menu. Noticed that I could change the Text elements color, so I did

jthi_0-1655563577790.png

2. Got the script for my graph builder with red text and found out that the color change affects TextSeg()

Graph Builder(
	Size(617, 457),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight)),
	Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{DispatchSeg(TextSeg(1), {Fill Color("Medium Dark Red")})}
		)
	)
)

3. Checked Scripting Index for Text Seg and found one way to get the value

jthi_1-1655563691720.png

 

-Jarmo

View solution in original post

7 REPLIES 7

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

Hi,

 

I'm not sure if there is a way to extract this number from a Graph Builder report, but it is quite simple to do it using Multivariate (see script below).  Does this work for you?

 

Names Default To Here(1);

dt=open("$SAMPLE_DATA/Tablet Production.jmp");



mul=dt<<Multivariate(
	Y( :Dissolution, :Mill Time ),
	Estimation Method( "Row-wise" ),
	Scatterplot Matrix( 1 )
);

corr_matrix=report(mul)[MatrixBox(1)]<<get;

show(corr_matrix);
Aslam0424
Level II

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

Hi HadelyMyers,

 

Thank you so much for the solution. In my data one column is numerical and the other one is categorical(Mostly characters). I am not sure how to use multivariate with this type of data. That is the reason I am using graph builder and density ellipse plot to see the correlation over there. Unfortunately, the solution you provide didn't work on my data. Hoping for your response.

 

Thank you again!

jthi
Super User

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

I'm not sure if you should be checking for correlation like this between Continuous and Nominal columns, but... you can export the correlation from graph builder with something like this (not sure how easily this will break):

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(535, 457),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight)),
	Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1)))
);

ts = Report(gb)[Frame Box(1)] << Find Seg("TextSeg");
corr = ts << get text;

How I got there:

1. Created graph builder and opened Customize menu. Noticed that I could change the Text elements color, so I did

jthi_0-1655563577790.png

2. Got the script for my graph builder with red text and found out that the color change affects TextSeg()

Graph Builder(
	Size(617, 457),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight)),
	Elements(Points(X, Y, Legend(3)), Ellipse(X, Y, Legend(5), Correlation(1))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{DispatchSeg(TextSeg(1), {Fill Color("Medium Dark Red")})}
		)
	)
)

3. Checked Scripting Index for Text Seg and found one way to get the value

jthi_1-1655563691720.png

 

-Jarmo
Aslam0424
Level II

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

Hi Jthi,

 

Thank you so much! It worked!!!

Based on my limited understanding, I thought this is one of the way to see correlation between numerical and categorical(which includes numbers and characters) data. I maybe wrong and I would love to explore any suggestions if you have.

 

Thanks again!!!

Aslam0424
Level II

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

I am not sure why I have started getting this error

 

too many arguments in access or evaluation of 'Contains'

Aslam0424_0-1658438649199.png

Here is my code..

ts = Report( gb1 )[Frame Box( 1 )] << Find Seg( "TextSeg" );
corr = ts << get text;
corr_num = Num( Contains( corr, "\D", "", GLOBALREPLACE ) );
jthi
Super User

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

Seems like you would like to use Regex() instead of Contains().

-Jarmo
txnelson
Super User

Re: Extract or return correlation values using density ellipse from a graph builder plots in JSL

The definition of the Contains() function is

txnelson_0-1658769967135.png

Your implementation of the function has 4 elements, where the Contains() function only handles 3 elements.  You will need to take a different approach.

Jim