home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / sm30a.zip / DOTPLOT.(X) < prev    next >
Text File  |  1993-11-14  |  796b  |  30 lines

  1. #    plot y=f(x) with dots on xy-plane
  2. #    by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
  3. #    e.g.    dotplot(x^3,x)
  4.  
  5. dotplot(y_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
  6.     dx:=(xmax-xmin)/getmaxx,
  7.     dy:=(ymax-ymin)/getmaxy,
  8.     xstep:=dx*10,
  9.     graph,
  10.     line(40,getmaxy-30,getmaxx,getmaxy-30),
  11.     line(40,0,40,getmaxy-30),
  12.     moveto(0,0),
  13.     writes(ymax),
  14.     moveto(0,getmaxy-30),
  15.     writes(ymin),
  16.     moveto(40,getmaxy-20),
  17.     writes(xmin),
  18.     moveto(getmaxx-30,getmaxy-20),
  19.     writes(xmax),
  20.     setviewport(40,0,getmaxx,getmaxy-30,1),
  21.     moveto(0,getmaxy-30),
  22.     do( putpixel((x-xmin)/dx,getmaxy-30-(y-ymin)/dy,15),
  23.     x,xmin,xmax,xstep),
  24.     numeric:=off,
  25.     readchar,
  26.     text,
  27.     local(dx,dy,xstep))
  28. dotplot(y_, x_, xmin_, xmax_) := dotplot(y,x,xmin,xmax,-5,5)
  29. dotplot(y_, x_) := dotplot(y,x,-5,5,-5,5)
  30.