cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-77396%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20Y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%E7%9B%B4%E7%B7%9A%E6%88%96%E5%A4%9A%E9%82%8A%E5%BD%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77396%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%A4%A7%E5%AE%B6%E5%A5%BD%E4%BD%A0%E5%80%91%E5%A5%BD%EF%BC%8C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E6%88%91%E7%9A%84%E6%83%85%E7%AF%80%E6%9C%89%E5%85%A9%E5%80%8B%20y%20%E8%BB%B8%E3%80%82%20%E6%88%91%E6%83%B3%E5%9C%A8%E8%85%B3%E6%9C%AC%E4%B8%AD%E5%81%9A%E7%9A%84%E6%98%AF%E7%95%AB%E7%B7%9A%E5%92%8C%E5%A4%9A%E9%82%8A%E5%BD%A2%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%8F%AF%E4%BB%A5%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%B8%80%E5%80%8B%20y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%EF%BC%8C%E4%BE%8B%E5%A6%82%3C%2FP%3E%3CP%3E%E5%A4%9A%E9%82%8A%E5%BD%A2(%20%5B0%2C1%2C2%5D%2C%20%5B1%2C%201%2C%203%5D%20)%3B%3C%2FP%3E%3CP%3E%E6%88%91%E5%A6%82%E4%BD%95%E5%91%8A%E8%A8%B4%20JMP%20%E6%88%91%E7%9A%84%E6%84%8F%E6%80%9D%E6%98%AF%20%5B1%2C%201%2C%203%5D%20%E9%97%9C%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20y%20%E8%BB%B8%EF%BC%9F%20%E6%88%91%E8%83%BD%E4%BB%A5%E6%9F%90%E7%A8%AE%E6%96%B9%E5%BC%8F%E5%9C%A8%E8%BB%B8%E4%B9%8B%E9%96%93%E5%88%87%E6%8F%9B%EF%BC%8C%E5%B0%B1%E5%83%8F%E9%A1%8F%E8%89%B2%E6%88%96%E7%B7%9A%E6%A2%9D%E6%A8%A3%E5%BC%8F%E4%B8%80%E6%A8%A3%E5%97%8E%EF%BC%9F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E8%AC%9D%E8%AC%9D%EF%BC%81%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77886%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20Y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%E7%B7%9A%E6%88%96%E5%A4%9A%E9%82%8A%E5%BD%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77886%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E9%80%99%E6%98%AF%E4%B8%80%E5%80%8B%E7%B0%A1%E5%96%AE%E7%9A%84%E4%BE%8B%E5%AD%90%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2Fsemiconductor%20capability.jmp%22%20)%3B%0A%0Agb%20%3D%20Graph%20Builder(%0A%20Variables(%20X(%20%3APNP2%20)%2C%20Y(%20%3ANPN1%20)%2C%20Y(%20%3APNP1%2C%20Position(%201%20)%2C%20Side(%20%22Right%22%20)%20)%20)%2C%0A%20Elements(%20Points(%20X%2C%20Y(%201%20)%2C%20Legend(%205%20)%20)%2C%20Points(%20X%2C%20Y(%202%20)%2C%20Legend(%207%20)%20)%20)%2C%0A%20SendToReport(%0A%20%20Dispatch(%0A%20%20%20%7B%7D%2C%0A%20%20%20%22PNP1%22%2C%0A%20%20%20ScaleBox%2C%0A%20%20%20%7BFormat(%20%22Best%22%2C%2010%20)%2C%20Min(%20100%20)%2C%20Max(%20540.816326530612%20)%2C%20Inc(%2050%20)%2C%20Minor%20Ticks(%201%20)%7D%0A%20%20)%0A%20)%0A)%3B%0A%0ANPN1y1%20%3D%20110%3B%0ANPN1y2%20%3D%20122%3B%0APNP1y1%20%3D%20300%3B%20%2F%2F%20Right%20side%20reference%0A%0Ax1%20%3D%20150%3B%0Ax2%20%3D%20250%3B%0Ax3%20%3D%20600%3B%0A%0AReport(%20gb%20)%5Bframebox(%201%20)%5D%20%26lt%3B%26lt%3B%20Add%20Graphics%20script(%0A%20leftMin%20%3D%20Report(%20gb%20)%5BAxisBox(%202%20)%5D%20%26lt%3B%26lt%3B%20get%20min%3B%0A%20leftMax%20%3D%20Report(%20gb%20)%5BAxisBox(%202%20)%5D%20%26lt%3B%26lt%3B%20get%20max%3B%0A%20%0A%20rightMin%20%3D%20Report(%20gb%20)%5BAxisBox(%203%20)%5D%20%26lt%3B%26lt%3B%20get%20min%3B%0A%20rightMax%20%3D%20Report(%20gb%20)%5BAxisBox(%203%20)%5D%20%26lt%3B%26lt%3B%20get%20max%3B%0A%20%0A%20xMat%20%3D%20Matrix(%20x1%20)%20%7C%7C%20Matrix(%20x2%20)%20%7C%7C%20Matrix(%20x3%20)%3B%0A%20%0A%20%2F%2F%20Calculate%20a%20left%20axis%20reference%20based%20upon%20right%20axix%20value%0A%20newMatY%20%3D%20leftMin%20%2B%20(leftMax%20-%20leftMin)%20*%20(PNP1y1%20-%20rightMin)%20%2F%20(rightMax%20-%20rightMin)%3B%0A%20%0A%20yMat%20%3D%20Matrix(%20NPN1y1%20)%20%7C%7C%20Matrix(%20NPN1y2%20)%20%7C%7C%20Matrix(%20NewMatY%20)%3B%0A%20%0A%20Transparency(%200.5%20)%3B%0A%20Fill%20Color(%20%7B1.0%2C%200.5%2C%200.0%7D%20)%3B%0A%20Polygon(%20xmat%2C%20yMat%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77880%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20Y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%E7%B7%9A%E6%88%96%E5%A4%9A%E9%82%8A%E5%BD%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77880%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%93%A6%EF%BC%8C%E6%89%80%E4%BB%A5%E4%BD%A0%E7%9A%84%E6%84%8F%E6%80%9D%E6%98%AF%3CBR%20%2F%3EY%20%E5%80%BC%E7%AC%AC%E4%BA%8C%E8%BB%B8%20--%26gt%3B%20%E7%8D%B2%E5%8F%96%E7%B9%AA%E5%9C%96%E7%AA%97%E5%8F%A3%2F%E5%B1%8F%E5%B9%95%E4%B8%8A%E7%9A%84%E5%83%8F%E7%B4%A0%E4%BD%8D%E7%BD%AE%20--%26gt%3B%20%E8%A8%88%E7%AE%97%E5%85%B7%E6%9C%89%E7%9B%B8%E5%90%8C%E5%83%8F%E7%B4%A0%E4%BD%8D%E7%BD%AE%E7%9A%84%E7%AC%AC%E4%B8%80%E8%BB%B8%E4%B8%8A%E7%9A%84%20Y%20%E5%80%BC%EF%BC%9F%3CBR%20%2F%3E%E4%BD%A0%E6%9C%89%E6%88%91%E7%9A%84%E4%BE%8B%E5%AD%90%E5%97%8E%EF%BC%9F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77879%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20Y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%E7%B7%9A%E6%88%96%E5%A4%9A%E9%82%8A%E5%BD%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77879%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E4%B8%A6%E4%B8%8D%E6%98%AF%E5%9C%A8%E6%9A%97%E7%A4%BA%E8%A6%81%E6%89%8B%E5%8B%95%E9%80%B2%E8%A1%8C%E3%80%82%E6%88%91%E7%9A%84%E6%84%8F%E6%80%9D%E6%98%AF%EF%BC%8C%E4%B8%80%E5%80%8B%E4%BA%BA%E7%A2%BA%E5%AF%A6%E5%8F%AF%E4%BB%A5%E9%80%9A%E9%81%8E%E7%B7%A8%E7%A8%8B%E8%A8%AA%E5%95%8F%E5%85%A9%E5%80%8B%E8%BB%B8%EF%BC%8C%E9%80%99%E5%B0%87%E5%85%81%E8%A8%B1%E4%B8%80%E5%80%8B%E4%BA%BA%E8%A8%88%E7%AE%97%20Y%20%E8%BB%B8%E4%BD%8D%E7%BD%AE%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77878%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20Y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%E7%B7%9A%E6%88%96%E5%A4%9A%E9%82%8A%E5%BD%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77878%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E7%95%B6%E7%84%B6%EF%BC%8C%E6%82%A8%E5%A7%8B%E7%B5%82%E5%8F%AF%E4%BB%A5%E9%80%9A%E9%81%8E%E8%BD%89%E6%8F%9B%E5%9D%90%E6%A8%99%E6%89%8B%E5%8B%95%E5%AE%8C%E6%88%90%E3%80%82%20%E4%BD%86%E6%98%AF%E7%95%B6%E6%82%A8%E8%87%B3%E5%B0%91%E6%9C%89%E4%B8%80%E5%80%8B%E9%9D%9E%E7%B7%9A%E6%80%A7%20y%20%E8%BB%B8%E6%99%82%EF%BC%8C%E4%BA%8B%E6%83%85%E6%9C%83%E8%AE%8A%E5%BE%97%E6%9B%B4%E5%8A%A0%E8%A4%87%E9%9B%9C%E3%80%82%20%E6%88%91%E5%B8%8C%E6%9C%9B%E6%9C%89%E4%B8%80%E5%80%8B%E6%9B%B4%E5%BF%AB%E7%9A%84%E9%81%B8%E6%93%87%E3%80%82%3C%2FP%3E%3CP%3E%E7%84%A1%E8%AB%96%E5%A6%82%E4%BD%95%EF%BC%8C%E6%84%9F%E8%AC%9D%E6%82%A8%E7%A2%BA%E8%AA%8D%E6%B2%92%E6%9C%89%E3%80%82%20%3CLI-EMOJI%20id%3D%22lia_winking-face%22%20title%3D%22%3Acara_gui%C3%B1ando_un_ojo%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77408%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%9B%B8%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%BA%8C%E5%80%8B%20Y%20%E8%BB%B8%E7%B9%AA%E8%A3%BD%E7%B7%9A%E6%88%96%E5%A4%9A%E9%82%8A%E5%BD%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77408%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%B2%92%E6%9C%89%E7%9C%8B%E5%88%B0%E8%BB%B8%E9%96%8B%E9%97%9C%EF%BC%8C%E4%BD%86%E6%98%AF%EF%BC%8C%E6%82%A8%E5%A7%8B%E7%B5%82%E5%8F%AF%E4%BB%A5%E7%8D%B2%E5%BE%97%E4%B8%8D%E5%90%8C%E8%BB%B8%E6%A1%86%E7%9A%84%E6%9C%80%E5%B0%8F%E5%80%BC%E5%92%8C%E6%9C%80%E5%A4%A7%E5%80%BC%EF%BC%8C%E7%84%B6%E5%BE%8C%E5%9C%A8%202%20%E5%80%8B%E5%88%BB%E5%BA%A6%E4%B9%8B%E9%96%93%E9%80%B2%E8%A1%8C%E6%8F%92%E5%80%BC%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Rob
Rob
Level II

Draw line or polygon with respect to second Y axis

Hi everybody,

 

my plot has two y axis. What I would like to do in a script is to draw lines and polygones.

I can draw with respect to the first y axis e.g. by

Polygon( [0,1,2], [1, 1, 3] );

How do I tell JMP that I mean [1, 1, 3] with respect to the second y axis? Can I switch between axis somehow just like the color or line style?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Draw line or polygon with respect to second Y axis

Here is a simple example

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

gb = Graph Builder(
	Variables( X( :PNP2 ), Y( :NPN1 ), Y( :PNP1, Position( 1 ), Side( "Right" ) ) ),
	Elements( Points( X, Y( 1 ), Legend( 5 ) ), Points( X, Y( 2 ), Legend( 7 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"PNP1",
			ScaleBox,
			{Format( "Best", 10 ), Min( 100 ), Max( 540.816326530612 ), Inc( 50 ), Minor Ticks( 1 )}
		)
	)
);

NPN1y1 = 110;
NPN1y2 = 122;
PNP1y1 = 300; // Right side reference

x1 = 150;
x2 = 250;
x3 = 600;

Report( gb )[framebox( 1 )] << Add Graphics script(
	leftMin = Report( gb )[AxisBox( 2 )] << get min;
	leftMax = Report( gb )[AxisBox( 2 )] << get max;
	
	rightMin = Report( gb )[AxisBox( 3 )] << get min;
	rightMax = Report( gb )[AxisBox( 3 )] << get max;
	
	xMat = Matrix( x1 ) || Matrix( x2 ) || Matrix( x3 );
	
	// Calculate a left axis reference based upon right axix value
	newMatY = leftMin + (leftMax - leftMin) * (PNP1y1 - rightMin) / (rightMax - rightMin);
	
	yMat = Matrix( NPN1y1 ) || Matrix( NPN1y2 ) || Matrix( NewMatY );
	
	Transparency( 0.5 );
	Fill Color( {1.0, 0.5, 0.0} );
	Polygon( xmat, yMat );
);
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Draw line or polygon with respect to second Y axis

I don't see an axis switch, however, you can always get the min and max for the different axis boxes and then interprolate between the 2 scales

Jim
Rob
Rob
Level II

Re: Draw line or polygon with respect to second Y axis

Of course you can always do it manually by transforming coordinates. But things get more complicated when you have at least one nonlinear y axis. I was hoping there is a faster option.

Thanks anyway for confirming there is none. ;-)

txnelson
Super User

Re: Draw line or polygon with respect to second Y axis

I was not implying to do it manually.  I was implying that one does have programatic access to both axes, which would allow one to calculate the Y axis position.

Jim
Rob
Rob
Level II

Re: Draw line or polygon with respect to second Y axis

Oh, so you mean something like
Y value second axis --> Get pixel position in plot window / on screen --> Calculate Y value on first axis with same pixel position?
Do you have an example for me?
txnelson
Super User

Re: Draw line or polygon with respect to second Y axis

Here is a simple example

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

gb = Graph Builder(
	Variables( X( :PNP2 ), Y( :NPN1 ), Y( :PNP1, Position( 1 ), Side( "Right" ) ) ),
	Elements( Points( X, Y( 1 ), Legend( 5 ) ), Points( X, Y( 2 ), Legend( 7 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"PNP1",
			ScaleBox,
			{Format( "Best", 10 ), Min( 100 ), Max( 540.816326530612 ), Inc( 50 ), Minor Ticks( 1 )}
		)
	)
);

NPN1y1 = 110;
NPN1y2 = 122;
PNP1y1 = 300; // Right side reference

x1 = 150;
x2 = 250;
x3 = 600;

Report( gb )[framebox( 1 )] << Add Graphics script(
	leftMin = Report( gb )[AxisBox( 2 )] << get min;
	leftMax = Report( gb )[AxisBox( 2 )] << get max;
	
	rightMin = Report( gb )[AxisBox( 3 )] << get min;
	rightMax = Report( gb )[AxisBox( 3 )] << get max;
	
	xMat = Matrix( x1 ) || Matrix( x2 ) || Matrix( x3 );
	
	// Calculate a left axis reference based upon right axix value
	newMatY = leftMin + (leftMax - leftMin) * (PNP1y1 - rightMin) / (rightMax - rightMin);
	
	yMat = Matrix( NPN1y1 ) || Matrix( NPN1y2 ) || Matrix( NewMatY );
	
	Transparency( 0.5 );
	Fill Color( {1.0, 0.5, 0.0} );
	Polygon( xmat, yMat );
);
Jim