cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
SpannerHead
Level IV

Auto Scaling

Following up with this.

 

https://community.jmp.com/t5/Discussions/Automatic-Scaling-Matching-X-and-Y-Axes/m-p/762890#M94321

 

I discovered a flaw in the script whereby excluded rows are not plotted but still factor in the graph scaling.  I need a way to eliminate those from y_there and x_there somehow.

 

dt = Current Data Table();
dt << Clear Column Selection();
colList = dt << get column names( string );
check_list = {"VT", "ID", "DI", "IK", "GM"};
New Window( "Select Variables",
	<<Modal,
	<<On Validate( window:validated ),
	window:enable function = Function( {},
		{Default Local},
		X = window:lbMajor << Get Selected;
		Y = window:lbMinor << Get Selected;
		If( N Items( X ) & N Items( Y ) & X != Y,
			window:validated = 1,
			window:validated = 0
		);
		window:ok button << Enable( window:validated );
	);
	H List Box(
		V List Box(
			Text Box( "Select X Variable" ),
			window:lbMajor = List Box(
				check_list,
				<<Set Max Selected( 1 ),
				enable function
			)
		),
		V List Box(
			Text Box( "Select Y Variable" ),
			window:lbMinor = List Box(
				check_list,
				<<Set Max Selected( 1 ),
				enable function
			)
		)
	);,
	H List Box(
		window:ok button = Button Box( "OK",
			X = window:lbMajor << Get Selected;
			Y = window:lbMinor << Get Selected;
			If( N Items( X ) & N Items( Y ) & X != Y,
				window:validated = 1,
				window:validated = 0
			);
			If( window:validated,
				Print( "Processing with X: " || Char( X ) || ", Y: " || Char( Y ) );
				Window( "Select Variables" ) << Close Window;
			,
				Beep();
				Show( "Invalid Selection" );
				{window:lbMajor, window:lbMinor} << Select;
				window:lbMajor << Inval << Update Window;
				Wait( 0.25 );
				{window:lbMajor, window:lbMinor} << DeSelect;
				window:lbMajor << Inval << Update Window;
				Wait( 0.25 );
				{window:lbMajor, window:lbMinor} << Select;
				window:lbMajor << Inval << Update Window;
				Wait( 0.25 );
				{window:lbMajor, window:lbMinor} << DeSelect;
				window:lbMajor << Inval << Update Window;
			);,
			<<Enable( 0 )
		),
		Button Box( "Cancel", Throw( "!Canceled Analysis" ) )
	)
);
If(
	X[1] == "VT", Xparam = "VT",
	X[1] == "ID", Xparam = "ID",
	X[1] == "DI", Xparam = "DI",
	X[1] == "IK", Xparam = "IK",
	X[1] == "GM", Xparam = "GM"
);
If(
	Y[1] == "VT", Yparam = "VT",
	Y[1] == "ID", Yparam = "ID",
	Y[1] == "DI", Yparam = "DI",
	Y[1] == "IK", Yparam = "IK",
	Y[1] == "GM", Yparam = "GM"
);
Show( Xparam );
Show( Yparam );
For( i = 1, i <= N Cols( dt ), i++,
	If(
		Contains( Munger( Head Name( As Namespace( colList[i] ) ), 0, 2 ), Xparam )
		 & Contains(
			Head Name( As Namespace( colList[i] ) ),
			"% Delta From Target"
		),
		Column( colList[i] ) << Set Selected( 1 )
	)
);
target = dt << get selected columns();
found_list = {};
Show( target );
New Window( "Compilation",
	For( j = 1, j <= N Items( target ), j++,
		Notes = target[j] << Get Property( "Notes" );
		If(
			Contains(
				Munger( Head Name( As Namespace( target[j] ) ), 0, 2 ),
				Xparam
			),
			Connected = Substitute( Head Name( As Namespace( target[j] ) ),
				Xparam, Yparam
			);
			Insert Into( found_list, Connected );
			Try(
				biv = Bivariate(
					Y( Column( dt, found_list[j] ) ),
					X( Column( dt, target[j] ) ),
					Automatic Recalc( 1 ),
					SendToReport(
						Dispatch(
							{},
							"Bivar Plot",
							FrameBox,
							{Frame Size( 470, 470 ),
							Add Text Annotation(
								Text( "Category: " || Notes ),
								Fixed Size( 0 ),
								Filled( 0 ),
								Font( "Segoe UI", 10, "Bold" )
							), Add Graphics Script(
								2,
								Description( "" ),
								Transparency( 0.5 );
								Pen Color( "Black" );
								Fill Color( "Red" );
								Oval( -100, -100, 100, 100, 1 );
								Pen Color( "Black" );
								Fill Color( "Green" );
								Oval( -90, -90, 90, 90, 1 );
								Pen Color( "Black" );
								Fill Color( "Blue" );
								Oval( -80, -80, 80, 80, 1 );
								Pen Color( "Black" );
								Line( [-110 0 110], [0 0 0] );
								Line( [0 0 0], [-110 0 110] );
								Oval( -80, -80, 80, 80 );
								Oval( -90, -90, 90, 90 );
								Oval( -100, -100, 100, 100 );
							)}
						)
					)
				);
				ms = Report( biv )[FrameBox( 1 )] << Find Seg( Marker Seg( 1 ) );
				xs = ms << Get X Values |/ 110;
				ys = ms << Get Y Values |/ 110;
				x_there = Loc( !Is Missing( xs ) );
				y_there = Loc( !Is Missing( ys ) );
				ind = Associative Array( x_there );
				ind << Intersect( Associative Array( y_there ) );
				ind = Matrix( ind << Get Keys );
				xs = xs[ind];
				ys = ys[ind];
				val = Max( Max( Abs( xs ) ), Max( Abs( ys ) ) );
				xaxis = Report( biv )[AxisBox( 1 )];
				yaxis = Report( biv )[AxisBox( 2 )];
				xaxis << Min( -1 * val ) << Max( val );
				yaxis << Min( -1 * val ) << Max( val );
			);
		);
	)
);

 

Help appreciated. 


Slán



SpannerHead
1 REPLY 1
jthi
Super User

Re: Auto Scaling

You can "pre-filter" your values, for example by getting non-excluded rows first

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << Select Rows(Index(7, 11)) << Hide and Exclude(1);


non_excluded_rows = dt << get rows where(!Excluded());


m = Column(dt, "height") << get values;

valid_m = m[non_excluded_rows];

N Items(valid_m);

show(valid_m, N Items(valid_m));

 

-Jarmo