cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
PhamBao
Level II

How to perform polygon offset outward in JMP

Hi all,

I would like to ask whether we could perform polygon offset outward in JMP. If yes, could you instruct me how to do it.
Assume I have coordinate of hexagon and I would like to draw buffer zone with distance =10 around hexagon. How could I do that

Thank a lot

6 REPLIES 6
txnelson
Super User

Re: How to perform polygon offset outward in JMP

Where is the original hexagon coming from?

Are you producing it using a JMP Graph Box?

 

More specific details will be very helpful

Jim
PhamBao
Level II

Re: How to perform polygon offset outward in JMP

Hi @txnelson,
The polygon gets from contour plot by saving contour

PhamBao_0-1750741477039.png

After saving contours, I plot X and Y Chart. How could I draw offset along polygon contour. THank a lot

PhamBao_2-1750741603513.png

 

txnelson
Super User

Re: How to perform polygon offset outward in JMP

JMP provides the ability to add to any graphic output additional graphic using Add Graphics Script.  The Scripting Index provides documentation and examples of how to add additional objects.

     Help=>Scripting Index

A complete set of graphic primitives are available in JSL.

Here is a simple example taken directly from the Scripting Guide that illustrates this capability

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate(
	Y( :weight ),
	X( :height ),
	FitLine
);
rbiv = biv << report;
framebox = rbiv[frame box( 1 )];
framebox <<
Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( {1.0, 0.5, 0.0} );
	Polygon( [60, 72, 57], [75, 120, 120] );
);

 

txnelson_0-1750754171858.png

 

Jim
PhamBao
Level II

Re: How to perform polygon offset outward in JMP

Hi @txnelson 
as your chart, we manually put number into graph to draw polygon. Is there anyway that we could do by scripting? For instance,
we got a list of coordinate in X and Y and have a distance. How could I perform calculation by scripting

In addition, I also would like to ask one question. When I plot Contour graph and save contour, JMP will generate out table with coordinate of X and Y. 
I faced the problem that when I use syntax such as In Polygon (a,b, x matrix, y matrix), it returns incorrect result. Even some points are inside polygon, but JMP returns these points out of Polygon

Do I need to perform sorting or process data before using In Polygon

Thanks

jthi
Super User

Re: How to perform polygon offset outward in JMP

Have you tried plotting the polygon you getting and does it look like what you expect?

-Jarmo
txnelson
Super User

Re: How to perform polygon offset outward in JMP

I am thinking that when you say that "we manually put number into graph", you are indicating that the JSL is "hard coded" for a specific polygon.  Yes that is true, but that does not mean that it has to be hard coded.  JSL is a complete scripting language.  The numerical values that define whatever polygon you want to generate can be calculated using JSL and then used within the Polygon() function to draw the polygon you want to be displayed.  I suspect that if what you want is to draw a polygon 10 units around the points that you are displaying, that you will probably have to loop through all of the values, calculating the distance from the mean of all of the x,y values to the specific point, and the add 10 units to the didtance, and then calculate the x,y point of that value.  Of something like that.  But that is all possible within JSL.  Below is a simple example of drawing a polygon to include the maximum x and y points.\

Names Default To Here( 1 );
dt=Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate(
	Y( :weight ),
	X( :height ),
	FitLine
);
rbiv = biv << report;
framebox = rbiv[frame box( 1 )];
framebox <<
Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( {1.0, 0.5, 0.0} );
	// Find the max X point and it's y value
	maxX = col max(:height);
	maxXyvalue = :weight[(dt << get rows where(:height==maxX))[1]];
	minX = col min(:height);
	minXyvalue = :weight[(dt << get rows where(:height==minX))[1]];	
	
	maxY = col max(:weight);
	maxYxvalue = :Height[(dt << get rows where(:weight==maxY))[1]];
	minY = col min(:weight);
	minYxvalue = :Height[(dt << get rows where(:weight==minY))[1]];
	polygon((maxX||minX||minYxvalue||maxYxvalue)`, (maxXyvalue || minXyvalue || minY ||maxY)` );
);

txnelson_0-1750879479436.png

 

 

Jim

Recommended Articles