Graphing In Programs

for Casio Graphic Calculators 7400, 9750/9850/9950, 9860, FX 1.0/Algebra FX 2.0

Basics

There are two display modes : text, and graph. Text mode is where all the calculations usually appear. When the display symbol has been used you can flip between modes using the G<->T button.

Both the Cls and ClrGraph commands clear the screen of the graph mode.

All graphic commands, Plot, Line, Graph etc. change the values stored in X and Y to the coordinates of the last point plotted. Using polar graphs also changes r and theta, and parametric graphs change T. So don't use these variables forsomething else while using these commands.

Older models have different screen sizes, so if you want to make a program behave the same on all models then take a note of the screen sizes on the History page.

After a Graph command if the program has any more commands after this and you want to study the completed graph you must put in a display symbol to pause it. E.g. Graph Y=sin X_ Press 'EXE' to continue.

Plots and Lines

But when you pause a plot statement it also displays the coordinates of that point and so obscures part of the picture, unless the coords have been turned off in setup or using the command CoordOff beforehand.

Here's a programming example using plots.

	CoordOff
	AxesOff
	GridOff
	ViewWindow 0,1,0,0,1,0
	Plot 0.5,0.5_ 		; _ represents the display symbol
	Lbl 2
	Plot X,Y_
	Line
	Goto 2
This is like a sketch pad. Use arrow keys to move the point. Press 'EXE' to plot a point. Then lines are drawn from one plotted point to the next as you go along.

As this example shows, when you use the plot command with the display symbol, a crosshair is displayed which you can move about with the cursor keys.

If you want to pause the program after a point has been plotted but don't want the crosshair then use the PlotOn command. Here's an example program which plots random points and waits after each point for 'EXE' to be pressed but doesn't allow the point to be moved about.

	CoordOff
	AxesOff
	GridOff
	ViewWindow 0,1,0,0,1,0
	Lbl 1
	PlotOn Ran#,Ran#_ 	; _ represents the display symbol
	Goto 1
The line command draws a line between the last two points plotted using the Plot command, but not the PlotOn command.

The PlotOff command clears a particular coordinate. The PlotChg command turns a coordinate on or off depending on current setting.

Instead of plotting two points and drawing a line between them
e.g. Plot 1,2:Plot 3,4:Line
you can combine this in one command using F-Line which just draws a line between specified points.
e.g. F-Line 1,2,3,4
Although in the sketch-pad example earlier where the plot command only happens once in the loop then the previous method is better.

Pixels

The plot command uses the coordinates of the ViewWindow settings. However you can change the physical screen pixels using the pixel commands regardless of what the ViewWindow settings are:
PxlOn 1,1	- turns pixel coordinate 1,1 on
PxlOff 1,1	- turns pixel coordinate 1,1 off
PxlChg 1,1 	- turns pixel coordinate 1,1 on or off opposite of
			current setting.
PxlTest 1,1	- returns 0 or 1 depending on whether coordinate 1,1
		  is on or off.
PxlTest cannot be used after the ClrGraph command, although it
can be used after the cls command.
The pixel coordinates go from the top left 1,1 to bottom right 63,127 and use row and column convention like matrices and not x,y axes like plots.

Text

In text mode, messages can be displayed using the locate command or just by using quotes e.g. "HELLO"_

However messages can also be displayed in graph mode (but not on the 7400 model) using the text command. e.g. Text 1,1,"HELLO". The coordinates used are the same as the pixel coordinates above. Numbers can be displayed without using quotes. Each character takes up 6 pixels in height and 4 pixels width.

There is a bug in the early 9850G models that means the Text command won't display anything until the next graphics command is reached. You can force it to display by adding PxlTest 1,1 or Text 1,1,"" each time you use Text.

Speeding up drawing of lines with Drawstat

To draw a series of connected lines, the Drawstat command draws faster than using the Line or F-line commands for each individual line.

First of all the x-coordinates of the points must be stored in a list, then the y-coodinates in another list. Various parameters for the Drawstat command must be setup. The Drawstat commmand will then join these points together. You can change the values stored in the lists and then use the Drawstat command again without having to setup the parameters again. The parameters only need to be setup once.

This example code draws a square, clears the screen, draws a triangle then starts again:

ViewWindow 0,5,1,0,5,1
FuncOff
S-WindMan
S-Gph1 DrawOn,xyLine,List 1,List 2,1,Dot,Blue
S-Gph2 DrawOff
S-Gph3 DrawOff
Lbl 0
Cls
{1,2,2,1}->List 1
{1,1,2,2}->List 2
DrawStat
Cls
{1,2,1}->List 1
{1,1,2}->List 2
DrawStat
Goto 0

On 7400 and 9x50 models, a disconnected set of lines (i.e. multiple shapes at the same time) can be drawn by putting a point outwith the ViewWindow range but this doesn't work on 9860, FX 1.0 or Algebra FX models where a line is drawn to a point even if it is offscreen.
e.g. Using {1,2,2,1,1,-8,4,5,4,4}->List 1 and {1,1,2,2,1,-8,4,4,5,4}->List 2 in the above code where the -8s are dummy values would draw two distinct shapes at the same time, but again this only works for particular models.

Starting from the top-level, the location of the commands is listed below.
Once entered into a command menu, keep pressing the [EXIT] button to get back to the top-level.

Keypresses beginning * mean you must be editing a program before pressing the rest.

9x50 models

Blue                * f4 f1 f5 f1
Cls                 shift f4 f1
Dot                 * f4 f1 f4 f3
DrawOff             * f4 f1 f1 f2
DrawOn              * f4 f1 f1 f1
DrawStat            shift vars f6 f2 f1
FuncOff             * shift menu f6 f6 f1 f2
Goto                shift vars f3 f2
Lbl                 shift vars f3 f1
List                optn f1 f1
S-Gph1              * f4 f1 f2 f1
S-WindMan           * shift menu f6 f6 f3 f2
ViewWindow          * shift f3 f1
xyLine              * f4 f1 f2 f5

7400 models

Blue                Omit this command. The 7400 doesn't use it.
Cls                 shift f4 f1
Dot                 * f3 f1 f4 f3
DrawOff             * f3 f1 f1 f2
DrawOn              * f3 f1 f1 f1
DrawStat            shift vars > f4 f1
FuncOff             Omit this command. The 7400 doesn't use it.
Goto                shift vars f3 f2
Lbl                 shift vars f3 f1
List                optn f1 f1
S-Gph1              * f3 f1 f2 f1
S-WindMan           shift menu > > > f2
ViewWindow          * shift f3 f1
xyLine              * f3 f1 f2 > f2

(c) Roy F. A. Maclean 1997, updated 17th March 2009
rfamgm at gmail
http://www.spiderpixel.co.uk/caspro