Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Draw line or polygon with respect to second Y axis

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 2, 2018 7:50 AM
(5630 views)

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

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

5 REPLIES 5

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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. ;-)

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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?

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?

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Article Labels

There are no labels assigned to this post.