home *** CD-ROM | disk | FTP | other *** search
- # library dataplot.li
- # dataplot()
- # plots data ( [x1,x2,...], [y1,y2,...] ) on xy-plane
- # dataplot( [x1,x2,...], [y1,y2,...], 1) plots a pair of data with
- # linked dots
- # dataplot( [x1,x2,...], [y1,y2,...], 0) plots a pair of data as dots
- # by default, link=0.
- # e.g. dataplot([1,2,3], [1,4,9])
-
- dataplot(x_, y_, link_) := block(numeric:=on,
- graph,
- xmax:=max(x)*1.1,
- xmin:=min(x)*0.9,
- ymax:=max(y)*1.1,
- ymin:=min(y)*0.9,
- getmaxy3:=getmaxy-30,
- getmaxy2:=getmaxy3+1,
- dx:=(xmax-xmin)/(getmaxx-40),
- dy:=(ymax-ymin)/(getmaxy-30),
- length:=length(y),
- line(40,getmaxy3,getmaxx,getmaxy3),
- line(40,0,40,getmaxy3),
- moveto(0,0),
- writes(ymax),
- moveto(0,getmaxy3),
- writes(ymin),
- moveto(35,getmaxy-20),
- writes(xmin),
- moveto(getmaxx-30,getmaxy-20),
- writes(xmax),
- setviewport(40,0,getmaxx,getmaxy3,1),
- moveto(0,getmaxy3),
- do( circle((member(x,j)-xmin)/dx,getmaxy2-(member(y,j)-ymin)/dy,2),
- j,1,length,1),
- setcolor(colorno(yellow)),
- moveto((member(x,1)-xmin)/dx,getmaxy2-(member(y,1)-ymin)/dy),
- if(link,do( lineto((member(x,j)-xmin)/dx,getmaxy2-(member(y,j)-ymin)/dy),
- j,1,length,1)),
- numeric:=off,
- readchar,
- text,
- local(dx,dy,length))
- dataplot(x_,y_) := dataplot(x,y,0)