Reference Guide

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:
«
RCLF flags
Recalls the current flag status and
stores it in variable flags.
«
RAD
Sets Radians mode.
{{ "SLICE" Σ+ }
{ }
{ "CLEAR" CLΣ }
{ } { }
{ "DRAW" CONT }}
Defines the input menu: key 1
executes
Σ
+ to store each data point
in
Σ
DAT, key 3 clears
Σ
DAT, and
key 6 continues program execution
after data entry.
TMENU
Displays the temporary menu.
"Key values into
SLICE,DRAW
restarts program."
PROMPT
Prompts for inputs.
represents the newline character
(
… ë
) after you enter the
program on the stack.
ERASE 1 131 XRNG
1 64 YRNG CLLCD
Erases the current PICT and sets plot
parameters.
"Please wait...
Drawing Pie Chart"
1 DISP
Displays “drawing” message.