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 yaxis 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" Σ+ }

Defines the input menu: key 1

{ }

executes Σ+ to store each data point

{ "CLEAR" CLΣ }

in ΣDAT, key 3 clears ΣDAT, and

{ } { }

key 6 continues program execution

{ "DRAW" CONT }}

after data entry.

 

TMENU

Displays the temporary menu.

"Key values into

Prompts for inputs.

SLICE,DRAW

represents the newline character

restarts program."

(Ë) after you enter the

PROMPT

program on the stack.

 

ERASE 1 131 XRNG

Erases the current PICT and sets plot

1 64 YRNG CLLCD

parameters.

"Please wait...

Displays “drawing” message.

Drawing Pie Chart"

 

1 DISP

 

 

 

234 RPL Programming Examples

Page 114
Image 114
HP 50g Graphing manual Programmatic Use of Statistics and Plotting, Techniques used in PIE, Temporary menu for data input