2-34 RPL Programming Examples
Programmatic Use of Statistics and Plotting
This section describes a program PIE you can use to draw pie charts. PIE prompts for single variable data,
stores that data in the statistics matrix
Σ
DAT, then draws a labeled pie chart that shows each data point as a
percentage of the total.
Techniques used in PIE
! Programmatic use of PLOT commands. PIE executes XRNG and YRNG to define x- and y-axis display
ranges in user units, and executes ARC and LINE to draw the circle and individual slices.
! Programmatic use of matrices and statistics commands.
! Manipulating graphics objects. PIE recalls PICT to the stack and executes GOR to merge the label for each
slice with the plot.
! FOR…NEXT (definite loop). Each slice is calculated, drawn, and labeled in a definite loop.
! CASE…END structure. To avoid overwriting the circle, each label is offset from the midpoint of the arc of
the slice. The offset for each label depends on the position of the slice in the circle. The CASE…END
structure assigns an offset to the label based on the position of the slice.
! Preserving calculator flag status. Before specifying Radians mode, PIE saves the current flag status in a
local variable, then restores that status at the end of the program.
! Nested local variable structures. At different parts of the process, intermediate results are saved in local
variables for convenient recall as needed.
! Temporary menu for data input.
PIE program listing
Program: Comments:
"!
KOE7!#!*u$mZ!
Recalls the current flag status
and stores it in variable flags.
"!
KB4!
ff!IDE6O<I!\'!h!
f!h!
f!IOE<BKI!OE\!h!
f!h!f!h!
f!I4KBYI!OL=:!hh!
Sets Radians mode.
Defines the input menu: key 1
executes Σ+ to store each data
oint in
Σ
DAT, key 3 clears
Σ
DAT, and key 6 continues
rogram execution after data
entry.
:M<=5!
Ir)@!w$un)Z!tGpk!
DE6O< !4KBY!
j)Zp$jpZ!qjkmj$odI!
2KLM2:!
Displays the temporary menu.
Prompts for inputs.
represents the newline
character (… ë) after you
enter the program on the stack.
<KBD<!3!3V3!TK=>!
3!ca!PK=>!OEEO4!
Erases the current PICT and
sets plot parameters.