  uses ConsoleG

  sub linescale(optional float r,a,b,w)
  =====================================
  float i
  float c,d
  if not r then r=10.00 'length of line
  if not a then a= 1.00 'tick interval
  if not b then b= 0.3  'tick size
  if not w then w= 5.0  'major interval count
  glLineWidth 2
  glBegin GL_LINES
  glVertex2f .0 , .0
  glVertex2f  r , .0
  glend
  'ticks
  glLineWidth 1
  glBegin GL_LINES
  do
    glVertex2f i,.0
    if mod(c,w)=0 then d=-b*2 else d=-b
    glVertex2f i,d
    i+=a
    c+=1.0
    if i>r then exit do
  end do
  glEnd
  end sub

  sub floatstr(double v, sys lp,dp) as string
  ===========================================
  string sf=string(lp,"0")
  string sv=str(v,dp)
  sys    le=len sv
  sys    pp=instr(sv,".")
  if dp then
    sf+="."+string(dp,"0")
    if pp=0 then le++ : pp=le
    pp=2+lp-pp
  else
    pp=1+lp-le
  end if
  if pp<1 then return sv
  mid sf,pp,sv
  return sf
  end sub

  sub numscale(double bx,by,nx,ny,b,n, sys lp,dp,i)
  =================================================
  int j
  for j=1 to i
    pushstate
    move bx,by
    string s=floatstr(b,lp,dp)
    print s
    popstate
    bx+=nx : by+=ny : b+=n
  next
  end sub

  sub LinePlot (sys n,float *f)
  =============================
  sys i,x,y
  glBegin GL_LINE_STRIP
  n=n+n
  for i=1 to n step 2
    glVertex2fv f[i]
  next
  glEnd
  end sub

  sub PointPlot (sys n,float *f)
  ==============================
  sys i,x,y
  glBegin GL_POINTS
  n=n+n
  for i=1 to n step 2
    glVertex2fv f[i]
  next
  glEnd
  end sub

  sub VertLinePlot (sys n,float *f)
  =================================
  sys i,j,x,y
  glBegin GL_LINES
  n=n+n
  for i=1 to n step 2
    j=i+1
    glVertex2f f[i],0.0
    glVertex2f f[i],f[j]
  next
  glEnd
  end sub

  sub HorzLinePlot (sys n,float *f)
  =================================
  sys i,j,x,y
  glBegin GL_LINES
  n=n+n
  for i=1 to n step 2
    j=i+1
    glVertex2f 0.0, f[j]
    glVertex2f f[i],f[j]
  next
  glEnd
  end sub

  sub VertBarPlot (sys n,float *f,w)
  ==================================
  sys i,j,x,y
  n=n+n
  glBegin GL_QUADS
  for i=1 to n step 2
    j=i+1
    glVertex2f   f[i] , 0.0
    glVertex2f w+f[i] , 0.0
    glVertex2f w+f[i] , f[j]
    glVertex2f   f[i] , f[j]
  next
  glEnd
  end sub

  sub HorzBarPlot (sys n,float *f,w)
  ==================================
  sys i,j,x,y
  n=n+2
  glBegin GL_QUADS
  for i=1 to n step 2
    j=i+1
    glVertex2f   0.0 , f[j]
    glVertex2f   f[i], f[j]
    glVertex2f   f[i], f[j]+w
    glVertex2f   0.0 , f[j]+w
  next
  glEnd
  end sub

  sub LinePlot3d (sys n,float *f)
  ===============================
  sys i,x,y
  glBegin GL_LINE_STRIP
  n=n*3
  for i=1 to n step 3
    glVertex3fv f[i]
  next
  glEnd
  end sub

  sub PointPlot3d (sys n,float *f)
  ================================
  sys i,x,y
  glBegin GL_POINTS
  n=n*3
  for i=1 to n step 3
    glVertex3fv f[i]
  next
  glEnd
  end sub

  sub ObjectPlot3d (sys n,float *f, sys obj)
  ==========================================
  sys i,j,k
  n=n*3
  for i=1 to n step 3
    j=i+1 : k=i+2
    glPushMatrix
    glTranslatef   f[i] , f[j] , f[k]
    go obj
    glPopMatrix
  next
  end sub

  sub VertBarPlot3d (sys n,float *f,w)
  ====================================
  sys i,j,k
  float h
  n=n*3
  for i=1 to n step 3
    j=i+1 : k=i+2 : h=f[j]/2
    glPushMatrix
    glTranslatef   f[i] , h , f[k]
    glScalef       w    , h , w
    go cube
    glPopMatrix
  next
  end sub

  sub VertRodPlot3d (sys n,float *f,w)
  ====================================
  sys i,j,k
  float h
  n=n*3
  for i=1 to n step 3
    j=i+1 : k=i+2 : h=f[j]
    glPushMatrix
    glTranslatef   f[i] , 0 , f[k]
    glScalef       w    , h , w
    go cylinder
    glPopMatrix
  next
  end sub
