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%3EDessiner%20une%20ligne%20ou%20un%20polygone%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20Y%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77396%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESalut%20tout%20le%20monde%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Emon%20intrigue%20a%20deux%20axes%20y.%20Ce%20que%20je%20voudrais%20faire%20dans%20un%20script%2C%20c'est%20dessiner%20des%20lignes%20et%20des%20polygones.%3C%2FP%3E%3CP%3EJe%20peux%20dessiner%20par%20rapport%20au%20premier%20axe%20y%2C%20par%20exemple%20en%3C%2FP%3E%3CP%3EPolygone(%20%5B0%2C1%2C2%5D%2C%20%5B1%2C%201%2C%203%5D%20)%3B%3C%2FP%3E%3CP%3EComment%20dire%20%C3%A0%20JMP%20que%20je%20veux%20dire%20%5B1%2C%201%2C%203%5D%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20y%26nbsp%3B%3F%20Puis-je%20basculer%20entre%20les%20axes%20d'une%20mani%C3%A8re%20ou%20d'une%20autre%2C%20tout%20comme%20la%20couleur%20ou%20le%20style%20de%20ligne%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMerci!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77886%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Dessiner%20une%20ligne%20ou%20un%20polygone%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20Y%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77886%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVoici%20un%20exemple%20simple%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%3ERe%26nbsp%3B%3A%20Dessiner%20une%20ligne%20ou%20un%20polygone%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20Y%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77880%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EOh%2C%20donc%20tu%20veux%20dire%20quelque%20chose%20comme%3CBR%20%2F%3E%20Deuxi%C3%A8me%20axe%20de%20la%20valeur%20Y%20--%26gt%3B%20Obtenir%20la%20position%20du%20pixel%20dans%20la%20fen%C3%AAtre%20de%20trac%C3%A9%20%2F%20%C3%A0%20l'%C3%A9cran%20--%26gt%3B%20Calculer%20la%20valeur%20Y%20sur%20le%20premier%20axe%20avec%20la%20m%C3%AAme%20position%20de%20pixel%26nbsp%3B%3F%3CBR%20%2F%3E%20Avez-vous%20un%20exemple%20pour%20moi%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77879%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Dessiner%20une%20ligne%20ou%20un%20polygone%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20Y%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77879%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJe%20ne%20voulais%20pas%20le%20faire%20manuellement.Je%20sous-entendais%20que%20l'on%20avait%20un%20acc%C3%A8s%20programmatique%20aux%20deux%20axes%2C%20ce%20qui%20permettrait%20de%20calculer%20la%20position%20de%20l'axe%20Y.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77878%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Dessiner%20une%20ligne%20ou%20un%20polygone%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20Y%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77878%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EBien%20s%C3%BBr%2C%20vous%20pouvez%20toujours%20le%20faire%20manuellement%20en%20transformant%20les%20coordonn%C3%A9es.%20Mais%20les%20choses%20se%20compliquent%20lorsque%20vous%20avez%20au%20moins%20un%20axe%20y%20non%20lin%C3%A9aire.%20J'esp%C3%A9rais%20qu'il%20y%20avait%20une%20option%20plus%20rapide.%3C%2FP%3E%3CP%3EMerci%20quand%20m%C3%AAme%20de%20confirmer%20qu'il%20n'y%20en%20a%20pas.%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%3ERe%26nbsp%3B%3A%20Dessiner%20une%20ligne%20ou%20un%20polygone%20par%20rapport%20au%20deuxi%C3%A8me%20axe%20Y%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77408%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJe%20ne%20vois%20pas%20de%20commutateur%20d'axe%2C%20cependant%2C%20vous%20pouvez%20toujours%20obtenir%20le%20min%20et%20le%20max%20pour%20les%20diff%C3%A9rentes%20cases%20d'axe%2C%20puis%20intercaler%20entre%20les%202%20%C3%A9chelles%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