cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Hans_Hsu
Level I

How to create XY axis data for a circle and key into data table

I would like to draw a circle in graph builder.

I know that one way is using "customize" function in graph build, then use code like below to draw a circle

Pen Color( "orange" );
Pen Size( 2 );
Circle( {0, 0}, 100 );

 

But I need another way, that is, provide X,Y data in data table, then draw a X-Y map in graph builder

Approximately  50 points data of a circle would be enough for me 

So is there any way to quickly generate XY data for a circle?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to create XY axis data for a circle and key into data table

Here is one way to generate it

circle.PNG

Names Default To Here( 1 );
dt = New Table( "circle", New Column( "x" ), New Column( "y" ) );

radius = 100;
        
r2 = radius * radius;
For( x = -radius, x <= radius, x++,
	y = floor(Sqrt( r2 - x * x ) + 0.5);
	dt<<add rows( 1 );
	dt:x[N Rows( dt )] = x;
	dt:y[N Rows( dt )] = y;
	dt<<add rows( 1 );
	dt:x[N Rows( dt )] = x;
	dt:y[N Rows( dt )] = -1*y;
);

Graph Builder(
	Size( 506, 501 ),
	Variables( X( :x ), Y( :y ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: How to create XY axis data for a circle and key into data table

Here is one way to generate it

circle.PNG

Names Default To Here( 1 );
dt = New Table( "circle", New Column( "x" ), New Column( "y" ) );

radius = 100;
        
r2 = radius * radius;
For( x = -radius, x <= radius, x++,
	y = floor(Sqrt( r2 - x * x ) + 0.5);
	dt<<add rows( 1 );
	dt:x[N Rows( dt )] = x;
	dt:y[N Rows( dt )] = y;
	dt<<add rows( 1 );
	dt:x[N Rows( dt )] = x;
	dt:y[N Rows( dt )] = -1*y;
);

Graph Builder(
	Size( 506, 501 ),
	Variables( X( :x ), Y( :y ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);
Jim