cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
EugeneB
Level III

Select rotation and data columns from 3D scatterplot plot script

We are generating a script to automate production of 2D X Y coordinate columns from a user-selected 3D graph orientation.  The script will call an R code to perform the calculations, but needs to provide the XYZ column data and the rotation settings to R.   

 

From a saved scatterplot 3D script we can see the XYZ column names  (zue1...) and the rotation settings (-8....).   We need jsl code to select those columns and export a csv file .   And code to select and export the values of the rotation settings.  

 

Any advice would be appreciated.  

 

 

 

 

 

 

 

Scatterplot 3D(
	Y( :zue1, :zue2, :zue3 ), 
	Frame3D(
		Set Grab Handles( 0 ),
		Set Rotation( -8.15592033195416, 47.3040538060599, 75.4291344975828 )
	)
);
5 REPLIES 5
ian_jmp
Level X

Re: Select rotation and data columns from 3D scatterplot plot script

Rather than using CSV files as an intermediary, you might like to look into the JMP and R integration.

txnelson
Super User

Re: Select rotation and data columns from 3D scatterplot plot script

@ian_jmp suggestion of calling the R routines from JMP might really be a great way of solving the problem.

If you really need to use a csv pass through data table, here is a simple example of one way to accomplish the creation of a csv file

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
sp = Scatterplot 3D(
	Y( :age, :height, :weight ),
	Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
sp << on close(
	theScript = Char( (Report( sp ) << get scriptable object) << get script );
	varsList = {};
	Insert Into( varsList, Word( 2, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
	Insert Into( varsList, Word( 4, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
	Insert Into( varsList, Word( 6, Substr( theScript, Contains( theScript, "Y(" ) ), ":,)" ) );
	rotationList = {};
	Insert Into( rotationList, Word( 2, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
	Insert Into( rotationList, Word( 3, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
	Insert Into( rotationList, Word( 4, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
	dtSub = dt << subset( columns( Eval( varsList ) ), selected rows( 0 ) );
	dtSub << New Column( "_Vars_", character, set values( varsList ) );
	dtSub << New Column( "_Rotation_", character, set values( rotationList ) );
	dtSub << Save( "$TEMP/passvalues.csv" );
	close( dtSub, nosave );
);

// This line opens the csv back into JMP 
//open("$TEMP/passvalues.csv");
Jim
EugeneB
Level III

Re: Select rotation and data columns from 3D scatterplot plot script

Thanks to you both.  We will pass the values directly to R as you suggest.   However..... our fundamential question (which was lost in framing our goal overall) is......   how can we have a jsl script select the rotation values (-8...)   and  the column data (zue1,... in this exmple) to pass to R.  We want the user to make a desired 3D projection, orient it as desired, and then have the script generate a 2D projection from that orientation.   We need to access and select the  rotation values, from (or as seen in) the saved 3D scatterplot script.   We'd also like the script or addin we make automatically select (for export to R) the  column data used, so select the XYZ column data used for the original 3D plot.

 

 

 

Here is the 3D scatterplot script.... 

 

thanks!

Scatterplot 3D(
	Y( :zue1, :zue2, :zue3 ), 
	Frame3D(
		Set Grab Handles( 0 ), 
		Set Rotation( -8.15592033195416, 47.3040538060599, 75.4291344975828 )
	)
);
txnelson
Super User

Re: Select rotation and data columns from 3D scatterplot plot script

Please take the time again to review the JSL I provided.  It's example, runs a Scatterplot 3D, where you can change the rotation to where ever you want it, then upon closing of the window, it extracts the script for the example, and strips out the variables and the rotation values from the example just run.  It then creates a csv file and saves it to disk.  If you do not want the complete code I provided, you can easily see the code that I used to strip out the variables and rotation values, placing them into JMP Lists called varsList and rotationList.

Jim
EugeneB
Level III

Re: Select rotation and data columns from 3D scatterplot plot script

Oh I see that your script has (I think) what we need within it. thanks. Willl try to implement using these insights.