help polarVersion 1.0

Title

polor -- Plot polar coordinates.

Syntax

polar
radius_var
angle_var
[if]
[in]
[, options]

Description

This command takes data expressed in polar coordinates and plots the points on a polar grid. The polar coordinates of a point
can be thought of as the parameters of a vector ("ray") that connects the origin ("pole") to the point. Thus, polar coordinates are expressed in terms of the
length of the vector (called the radius or radial coordinate, the distance from the origin to the point; denoted by the letter r)
and the angle between the positive x-axis and the vector (called the angular coordinate, polar angle, or azimuth; often denoted by the letter t
or the Greek letters theta or phi). By default, the command assumes that angles are specified in radians.

The polar grid includes several concentric circles and several grid lines. By default, three concentric circles are plotted, along with grid lines at
0, 30, 60, 90, 120, and 150 degrees from the positive x-axis.

Options

ncc(#) Specify the number of concentric circles used to display the polar grid. To determine the radius of each concentric circle,
the maximum radius value in the data set is computed and divided into # equal intervals. Only one of the ncc and cc options
can be specified. If neither the ncc nor cc options are specified, ncc defaults to 3.

cc(numlist) Specify the the precise locations (radii) of concentric circles used to display the polar grid. No checking is
done to determine whether the specified values are consistent with the range of radii in the data set.
Only one of the ncc and cc options can be specified.

nspokes(#) Specify the number of spokes to display on the polar grid. To determine the angle of each spoke with respect to the positve x-axis,
the positive half of the unit circle is divied into # equal intervals. Spokes are drawn symmetric to the origin: i.e., from above the x-axis,
through the origin, to below the x-axis. Thus, the number of spokes in each quadrant is half of the specified number of spokes.
Only one of the nspokes and spokes options can be specified.
If neither the nspokes nor spokes options are specified, nspokes defaults to 6.

spokes(numlist) Specify the the precise locations of spokes used to display the polar grid. For convenience, angles are specified
in degrees relative to the positive x-axis. Since spokes are drawn symmetric to the origin and extend to both above and below the x-axis,
only angles from 0 to 180 degrees need to specified. Only one of the nspokes and spokes options can be specified.

degrees Indicates that angle measurements in the input data set are in degrees rather than radians.

scatteropts(twoway_scatter_options) Any twoway scatter options, such as those controlling markers,
connecting lines, etc., can be specified and will be passed on to twoway without processing.

twoway_options Any twoway options, such as those controlling titles, legends,
axes, etc., can be specified and will be passed on to twoway without processing.

Examples

. // Set up Polar Rose

. set obs 360

. gen theta=_n*2*_pi/360

. gen r=2*cos(3*theta)

. polar r theta

. polar r theta, cc(4)

. polar r theta, cc(.5(0.5)2)

. polar r theta, nsp(8)

. polar r theta, sp(30 45 60 120 135 150)

. polar r theta, sc(mcolor(red)

. polar r theta, title("Polar Rose")

. // Set up Archimedes spiral

. set obs 720

. gen theta=_n

. gen r=1+2*theta

. polar r theta, deg

. // Other shapes

. gen r=0.5+0.5*sin(theta) // Cardiod

. gen r=1 // Circle with radius 1

. gen r=1/(1+cos(theta)) // Parabola

. gen r=1/(1+0.5*cos(theta)) // Ellipse

. gen r=1/(1+1.5*cos(theta)) // Hyperbola

Note: Be careful with the conic sections, since the denominator can equal zero for certain values of theta

Author

Joseph Canner

Johns Hopkins University School of Medicine

Department of Surgery

Center for Surgical Trials and Outcomes Research

Email jcanner1@jhmi.edu