This program, scatterf(), draws this type of scatter plot.
scatterf(f,x,xl,xh,yl,yh,n)
Prgm
©("f(var)","var",xmin,xmax,ymin,ymax,its)
©Function scatterplot with random points
©13aug01 dburkett@infinet.com
local k,e
false→e
©Clear graph screen
clrgraph
clrdraw
plotsoff
fnoff
clrio
©Set x- & y-axis ranges
xl→xmin
xh→xmax
yl→ymin
yh→ymax
©Loop to plot the function points
for k,1,n
if getkey()≠0:exit
(xh-xl)*rand()+xl→xn
expr(f&"|"&x&"="&format(xn,"S12"))→yn
if yn<ymin or yn>ymax then
true→e
pxltext "range error",0,0
disp "Range error: "&string(yn)
else
pton xn,yn
endif
endfor
©Delete global variables
delvar xn,yn
©Display range errors on prgm I/O screen
if e:disp
EndPrgm
The input arguments are
The number of points to plotn
The y-axis maximumyh
The y-axis minimumyl
The x-axis maximumxh
The x-axis minimumxl
The name of the independent variable, passed as a string.x
The name of the function to plot, passed as a string. f
4 - 17