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%3EZeichnen%20Sie%20eine%20Linie%20oder%20ein%20Polygon%20in%20Bezug%20auf%20die%20zweite%20Y-Achse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77396%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHallo%20zusammen%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMein%20Diagramm%20hat%20zwei%20Y-Achsen.%20Was%20ich%20in%20einem%20Skript%20tun%20m%C3%B6chte%2C%20ist%20das%20Zeichnen%20von%20Linien%20und%20Polygonen.%3C%2FP%3E%3CP%3EIch%20kann%20in%20Bezug%20auf%20die%20erste%20Y-Achse%20z.%20B.%20zeichnen%3C%2FP%3E%3CP%3EPolygon(%20%5B0%2C1%2C2%5D%2C%20%5B1%2C%201%2C%203%5D%20)%3B%3C%2FP%3E%3CP%3EWie%20sage%20ich%20JMP%2C%20dass%20ich%20%5B1%2C%201%2C%203%5D%20in%20Bezug%20auf%20die%20zweite%20y-Achse%20meine%3F%20Kann%20ich%20irgendwie%20zwischen%20den%20Achsen%20wechseln%2C%20genau%20wie%20bei%20der%20Farbe%20oder%20dem%20Linienstil%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDanke!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77886%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Zeichnen%20Sie%20eine%20Linie%20oder%20ein%20Polygon%20in%20Bezug%20auf%20die%20zweite%20Y-Achse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77886%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHier%20ist%20ein%20einfaches%20Beispiel%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%3EBetreff%3A%20Zeichnen%20Sie%20eine%20Linie%20oder%20ein%20Polygon%20in%20Bezug%20auf%20die%20zweite%20Y-Achse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77880%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EOh%2C%20also%20meinst%20du%20so%20etwas%20wie%3CBR%20%2F%3E%20Y-Wert%20zweite%20Achse%20-%26gt%3B%20Pixelposition%20im%20Plotfenster%2Fauf%20dem%20Bildschirm%20abrufen%20-%26gt%3B%20Y-Wert%20auf%20der%20ersten%20Achse%20mit%20derselben%20Pixelposition%20berechnen%3F%3CBR%20%2F%3E%20Hast%20du%20ein%20Beispiel%20f%C3%BCr%20mich%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77879%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Zeichnen%20Sie%20eine%20Linie%20oder%20ein%20Polygon%20in%20Bezug%20auf%20die%20zweite%20Y-Achse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77879%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20wollte%20es%20nicht%20manuell%20machen.Ich%20habe%20angedeutet%2C%20dass%20man%20programmgesteuerten%20Zugriff%20auf%20beide%20Achsen%20hat%2C%20was%20es%20einem%20erm%C3%B6glichen%20w%C3%BCrde%2C%20die%20Position%20der%20Y-Achse%20zu%20berechnen.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-77878%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Zeichnen%20Sie%20eine%20Linie%20oder%20ein%20Polygon%20in%20Bezug%20auf%20die%20zweite%20Y-Achse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77878%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ENat%C3%BCrlich%20k%C3%B6nnen%20Sie%20dies%20jederzeit%20manuell%20tun%2C%20indem%20Sie%20die%20Koordinaten%20transformieren.%20Aber%20die%20Sache%20wird%20komplizierter%2C%20wenn%20Sie%20mindestens%20eine%20nichtlineare%20y-Achse%20haben.%20Ich%20hatte%20gehofft%2C%20dass%20es%20eine%20schnellere%20Option%20gibt.%3C%2FP%3E%3CP%3EVielen%20Dank%20trotzdem%20f%C3%BCr%20die%20Best%C3%A4tigung%2C%20dass%20es%20keine%20gibt.%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%3EBetreff%3A%20Zeichnen%20Sie%20eine%20Linie%20oder%20ein%20Polygon%20in%20Bezug%20auf%20die%20zweite%20Y-Achse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-77408%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20sehe%20keinen%20Achsenschalter%2C%20Sie%20k%C3%B6nnen%20jedoch%20jederzeit%20die%20Mindest-%20und%20H%C3%B6chstwerte%20f%C3%BCr%20die%20verschiedenen%20Achsenfelder%20ermitteln%20und%20dann%20zwischen%20den%20beiden%20Skalen%20interprolatieren%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