cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Neo
Neo
Level VI

Cross section of a 2D plot

How to I plot the variation in a 2D plot along say vertically in a 1D line plot in JMP?

I am coming from Matlab (an equivalent in MATLAB is something like this )

Thanks, 

 

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Cross section of a 2D plot

Not sure if your 2D plot it based on points or a formula. If points, you could use graph builder to plot your target value against one dimension in your chart with a data filter to define the 'slice' in the other dimension.

 

ih_0-1623416878851.png

 

If you are exploring a column formula, then I agree with @Mark_Bailey that the profiler is the easiest approach. Just change the value of one value and see the plot on the other.

 

ih_1-1623417679550.png

 

Below are scripts for both:

Names default to here(1);

dt = Open("$Sample_data/iris.jmp");

New Column("H1_1", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(TanH(0.5 * ((-3.50407799736543) + -1.69201212624413 * :Sepal length + 4.45798369366822 * :Sepal width))), Set Property("Intermediate", 1));
New Column("H1_2", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(TanH(0.5 * ((-4.34695576142641) + 0.578814453314083 * :Sepal length + -0.387699136913814 * :Sepal width))), Set Property("Intermediate", 1));
New Column("H1_3", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(TanH(0.5 * ((-14.9199578715582) + 8.0363609653296 * :Sepal length + -9.32672254743267 * :Sepal width))), Set Property("Intermediate", 1));
New Column("Predicted Petal length", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(9.72824082889675 + 0.825393378043811 * :H1_1 + 8.38378988028562 * :H1_2 + 1.62929374850912 * :H1_3), Set Property("Predicting", {:Petal length, Creator("Neural")}));

New Window("Plotting points",
	H List Box(
		Graph Builder(
			Size( 522, 456 ),
			Show Control Panel( 0 ),
			Variables( X( :Sepal length ), Y( :Petal length ) ),
			Elements( Points( X, Y, Legend( 295 ) ), Line( X, Y, Legend( 297 ) ) ),
			Local Data Filter(
				Add Filter(
					columns( :Sepal width ),
					Where( :Sepal width >= 2.9 & :Sepal width <= 3.1 )
				)
			)
		),
		Contour Plot(
			X( :Sepal width, :Sepal length ),
			Y( :Petal length ),
			Show Data Points( 0 ),
			Fill Areas( 0 ),
			Label Contours( 0 ),
			Transform( "Range Normalized" ),
			Specify Contours( Min( 2 ), Max( 6 ), N( 5 ) ),
			SendToReport(
				Dispatch(
					{},
					"1",
					ScaleBox,
					{Add Ref Line(
						{2.9, 3.1},
						"Solid",
						"Medium Dark Magenta",
						"Slice",
						1,
						0.25
					)}
				)
			)
		)
	)
);

//Profiler
Profiler(
	Y( :Predicted Petal length ),
	Profiler(
		1,
		Term Value(
			Sepal length( 6.302, Lock( 0 ), Show( 1 ) ),
			Sepal width( 3.125, Lock( 0 ), Show( 1 ) )
		)
	),
	Expand,
	SendToReport(
		Dispatch(
			{"Prediction Profiler"},
			"Profiler",
			FrameBox,
			{Frame Size( 320, 260 )}
		),
		Dispatch(
			{"Prediction Profiler"},
			"Profiler",
			FrameBox( 3 ),
			{Frame Size( 320, 260 )}
		)
	)
);

 

Updated: added column formulas for prediction column to script. 

View solution in original post

8 REPLIES 8

Re: Cross section of a 2D plot

Please the book in JMP Help about the Profilers.

Neo
Neo
Level VI

Re: Cross section of a 2D plot

Thanks, The profilers option looks useful, but there are a lot of options. I will look into it.
What I was looking for is a a script based approach.
For a 2D plot, how to get a x-slice (for a give y-value) or a y-slice (for a given x-value). This is all I want to do at the moment.
When it's too good to be true, it's neither
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Cross section of a 2D plot

Not sure if your 2D plot it based on points or a formula. If points, you could use graph builder to plot your target value against one dimension in your chart with a data filter to define the 'slice' in the other dimension.

 

ih_0-1623416878851.png

 

If you are exploring a column formula, then I agree with @Mark_Bailey that the profiler is the easiest approach. Just change the value of one value and see the plot on the other.

 

ih_1-1623417679550.png

 

Below are scripts for both:

Names default to here(1);

dt = Open("$Sample_data/iris.jmp");

New Column("H1_1", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(TanH(0.5 * ((-3.50407799736543) + -1.69201212624413 * :Sepal length + 4.45798369366822 * :Sepal width))), Set Property("Intermediate", 1));
New Column("H1_2", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(TanH(0.5 * ((-4.34695576142641) + 0.578814453314083 * :Sepal length + -0.387699136913814 * :Sepal width))), Set Property("Intermediate", 1));
New Column("H1_3", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(TanH(0.5 * ((-14.9199578715582) + 8.0363609653296 * :Sepal length + -9.32672254743267 * :Sepal width))), Set Property("Intermediate", 1));
New Column("Predicted Petal length", Numeric, "Continuous", Format("Best", 12), Set Property("Notes", "Model NTanH(3)"), Formula(9.72824082889675 + 0.825393378043811 * :H1_1 + 8.38378988028562 * :H1_2 + 1.62929374850912 * :H1_3), Set Property("Predicting", {:Petal length, Creator("Neural")}));

New Window("Plotting points",
	H List Box(
		Graph Builder(
			Size( 522, 456 ),
			Show Control Panel( 0 ),
			Variables( X( :Sepal length ), Y( :Petal length ) ),
			Elements( Points( X, Y, Legend( 295 ) ), Line( X, Y, Legend( 297 ) ) ),
			Local Data Filter(
				Add Filter(
					columns( :Sepal width ),
					Where( :Sepal width >= 2.9 & :Sepal width <= 3.1 )
				)
			)
		),
		Contour Plot(
			X( :Sepal width, :Sepal length ),
			Y( :Petal length ),
			Show Data Points( 0 ),
			Fill Areas( 0 ),
			Label Contours( 0 ),
			Transform( "Range Normalized" ),
			Specify Contours( Min( 2 ), Max( 6 ), N( 5 ) ),
			SendToReport(
				Dispatch(
					{},
					"1",
					ScaleBox,
					{Add Ref Line(
						{2.9, 3.1},
						"Solid",
						"Medium Dark Magenta",
						"Slice",
						1,
						0.25
					)}
				)
			)
		)
	)
);

//Profiler
Profiler(
	Y( :Predicted Petal length ),
	Profiler(
		1,
		Term Value(
			Sepal length( 6.302, Lock( 0 ), Show( 1 ) ),
			Sepal width( 3.125, Lock( 0 ), Show( 1 ) )
		)
	),
	Expand,
	SendToReport(
		Dispatch(
			{"Prediction Profiler"},
			"Profiler",
			FrameBox,
			{Frame Size( 320, 260 )}
		),
		Dispatch(
			{"Prediction Profiler"},
			"Profiler",
			FrameBox( 3 ),
			{Frame Size( 320, 260 )}
		)
	)
);

 

Updated: added column formulas for prediction column to script. 

Neo
Neo
Level VI

Re: Cross section of a 2D plot

Thanks. My 2D plot is based on Xdata, Ydata and Data.

What you show with the data filter looks promising, but I cannot seem to get it to plot slice at one Xdata value (for all Ydata values) .

I will keep look this side but any direction will be very helpful. 

(I am on JMP13)

When it's too good to be true, it's neither
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Cross section of a 2D plot

Can you post some sample data and the script you have so far?

Craige_Hales
Super User

Re: Cross section of a 2D plot

Also, the contour plot (not graph builder's, use the contour platform) can save gridded data. As long as you want vertical or horizontal slices, it should be a row or column from the gridded data.

dt = Open( "$sample_data/big class.jmp" );
// step 1: use the contour plot to get a grid of the data
cp = dt << Contour Plot(
    X( :height, :weight ),
    Y( :age ),
    Show Data Points( 0 ),
    Fill Areas( 0 ),
    Label Contours( 0 ),
    Transform( "Range Normalized" ),
    Specify Contours( Min( 13 ), Max( 16.5 ), N( 8 ) )
);
nres = 100; // make this bigger if you think there is meaningful data there

dtGrid = cp << generate grid( nres, nres );

cp<<closewindow;
close(dt,nosave);
// step 2: make the cross section dtGrid:height<<setModelingType(nominal); dtGrid << Graph Builder( Size( 522, 525 ), Show Control Panel( 0 ), Variables( X( :weight ), Y( :age ) ), Elements( Points( X, Y, Legend( 204 ) ), Smoother( X, Y, Legend( 205 ) ) ), Local Data Filter( Add Filter( columns( :height ), Where( :height == 67.5050505050505 ), Display( :height, N Items( 15 ), Find( Set Text( "" ) ) ) ) ) );

Drive the height selector with up and down arrows.Drive the height selector with up and down arrows.

 

edit: The gridded data is extrapolated beyond the data points' envelope. The ends of the cross section probably go far into the extrapolated range. You'll probably want to match up the contour plot (closed, above, maybe keep it open) at height=61.5 (etc) to see what the valid range for weight would be. Even then, the contour plot is doing some linear interpolation across triangles formed by the data points. Big Class is not particularly smooth or dense, so you see a lot of weird artifacts that generate a false sense of detail, even inside the envelope of the data points.

Craige

Re: Cross section of a 2D plot

Ha! @ih beat me to it. I started a similar example but then I was in a meeting for three hours.

 

Names Default to Here( 1 );

dt = New Table( "Slicing",
	Add Rows( 2 ),
	New Column( "X",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [-1, 1] )
	),
	New Column( "Y",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [-1, 1] )
	),
	New Column( "Z",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			100 + 25 * :X - 3 * :X ^ 2 - 15 * :Y - 5 * :Y ^ 2 - 7 * :X * :Y
		)
	)
);

dt << Surface Plot(
	Columns( :Z ),
	Surface Color Theme( "Green to Black to Red" ),
	Surface Color Theme2( "Green to White to Red" ),
	Surface Color Theme3( "White to Black" ),
	Surface Color Theme4( "Blue to Gray to Red" ),
	Response Column Color Theme( "Blue to Green to Red" ),
	Response Column Color Theme2( "Spectral" ),
	Response Column Color Theme3( "Jet" ),
	Response Column Color Theme4( "White to Blue" ),
	Formula( "Z" ),
	Surface Color Method( "Solid", "Solid", "Solid", "Solid" ),
	SetVariableAxis( :X, Axis Data( {} ) ),
	SetVariableAxis( :Y, Axis Data( {} ) ),
	SetZAxis( :Z, Current Value( 95 ), Axis Data( {} ) ),
	SetXVariable( :X ),
	SetYVariable( :Y ),
	Iso Value( 0, 75 ),
	Frame3D( Set Rotation( -54, 0, 38 ) )
);

dt << Profiler(
	Y( :Z ),
	Profiler(
		1,
		Term Value( X( 0, Lock( 0 ), Show( 1 ) ), Y( 0, Lock( 0 ), Show( 1 ) ) )
	),
	SendToReport(
		Dispatch(
			{"Prediction Profiler"},
			"10000",
			ScaleBox,
			{Min( 72.5 ), Max( 125.754437869822 ), Inc( 10 ), Minor Ticks( 0 )}
		)
	)
);
hogi
Level XII

Re: Cross section of a 2D plot

A solution is now available via Graph Builder Toolbar 

hogi_0-1698354793606.png