DISLIN Examples / Python

Demonstration of CURVE / Python

#! /usr/bin/env python
import math
import dislin

n = 101
f = 3.1415926 / 180.
x = range (n)
y1 = range (n)
y2 = range (n)
for i in range (0,n):
  x[i] = i * 3.6
  v = i * 3.6 * f
  y1[i] = math.sin (v)
  y2[i] = math.cos (v)

dislin.scrmod ('revers')
dislin.metafl ('xwin')
dislin.disini ()
dislin.complx ()
dislin.pagera ()

dislin.axspos (450, 1800)
dislin.axslen (2200, 1200)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')

dislin.labdig (-1, 'X')
dislin.ticks  (9, 'X')
dislin.ticks  (10, 'Y')

dislin.titlin ('Demonstration of CURVE', 1)
dislin.titlin ('SIN (X), COS (X)', 3)

ic = dislin.intrgb (0.95, 0.95, 0.95)
dislin.axsbgd (ic)
 
dislin.graf   (0., 360., 0., 90., -1., 1., -1., 0.5)
dislin.setrgb (0.7, 0.7, 0.7)
dislin.grid   (1,1)

dislin.color  ('fore')
dislin.height (50)
dislin.title  ()

dislin.color  ('red')
dislin.curve  (x, y1, n)
dislin.color  ('green')
dislin.curve  (x, y2, n)
dislin.disfin ()

Polar Plots / Python

#! /usr/bin/env python
import math
import dislin

n = 300
m = 10
f = 3.1415927/180.
x1 = range (n)
y1 = range (n)
x2 = range (m) 
y2 = range (m)
step = 360./(n-1)
for i in range (0,n):
  a = (i * step) * f
  y1[i] = a
  x1[i] = math.sin (5*a)

for i in range (0,m):
  x2[i] = i + 1
  y2[i] = i + 1

dislin.scrmod ('revers')
dislin.setpag ('da4p')
dislin.metafl ('cons')
dislin.disini ()
dislin.hwfont ()
dislin.pagera ()

dislin.titlin ('Polar Plots', 2)
dislin.ticks  (3, 'Y')
dislin.axends ('NOENDS', 'X')
dislin.labdig (-1, 'Y')
dislin.axslen (1000, 1000)
dislin.axsorg (1050, 900)

ic = dislin.intrgb (0.95, 0.95, 0.95)
dislin.axsbgd (ic)

dislin.grafp  (1.,0., 0.2, 0., 30.)

dislin.color  ('blue')
dislin.curve  (x1, y1, n)
dislin.color  ('fore')
dislin.htitle (50)
dislin.title  ()
dislin.endgrf ()

dislin.labdig (-1, 'X')
dislin.axsorg (1050, 2250)
dislin.labtyp ('VERT', 'Y')
dislin.grafp  (10.,0.,2.,0.,30.)
dislin.barwth (-5.)
dislin.polcrv ('FBARS')
dislin.color  ('blue')
dislin.curve  (x2, y2, m)

dislin.disfin ()

Symbols / Python

#!/usr/bin/env python
import dislin

ctit = 'Symbols'

dislin.scrmod ('revers')
dislin.setpag ('da4p')
dislin.metafl ('cons')

dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.height (60)
nl = dislin.nlmess (ctit)
dislin.messag (ctit, (2100 - nl)/2, 200)

dislin.height (50)
dislin.hsymbl (120)

ny = 150

for i in range (0, 24):
  if (i % 4) == 0:
    ny = ny + 400
    nxp = 550
  else:
    nxp = nxp + 350

  nl = dislin.nlnumb (i, -1)
  dislin.number (i, -1, nxp - nl/2, ny + 150)
  dislin.symbol (i, nxp, ny)

dislin.disfin ()

Interpolation Methods / Python

#!/usr/bin/env python
import dislin

ctit = 'Interpolation Methods'

xray = [0., 1., 3., 4.5, 6., 8., 9., 11., 12., 12.5, 
        13., 15., 16., 17., 19., 20.]
yray = [2., 4., 4.5, 3., 1., 7., 2., 3., 5., 2., 2.5,
        2., 4., 6., 5.5, 4.]
cpol = ['SPLINE', 'BARS', 'STEP', 'LINEAR']

dislin.scrmod ('revers')
dislin.setpag ('da4p')
dislin.metafl ('cons')

dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.incmrk (1)
dislin.hsymbl (25)
dislin.titlin (ctit, 1)
dislin.axslen (1500, 500)
dislin.setgrf ('LINE', 'LINE', 'LINE', 'LINE')

ic = dislin.intrgb (1.0, 1.0, 0.0)
dislin.axsbgd (ic)

nya = 2700
for i in range (0, 4):
  dislin.axspos (350, nya - i * 500)
  dislin.polcrv (cpol[i])
  dislin.marker (0)
  dislin.graf   (0., 20., 0., 5., 0., 10., 0., 5.)
  nx = dislin.nxposn (1.)
  ny = dislin.nyposn (8.)
  dislin.messag (cpol[i], nx, ny)
  dislin.color  ('red')
  dislin.curve  (xray, yray, 16)
  dislin.color  ('fore')

  if i == 3:
    dislin.height (50)
    dislin.title ()

  dislin.endgrf ()

dislin.disfin ()

Bar Graphs / Python

#!/usr/bin/env python
import dislin

x  = [1., 2., 3., 4., 5., 6., 7., 8., 9.]
y  = [0., 0., 0., 0., 0., 0., 0., 0., 0.]
y1 = [1., 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1]
y2 = [2., 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8]
y3 = [4., 3.5, 4.5, 3.7, 4., 2.9, 3.0, 3.2, 2.6]

nya = 2700
ctit = 'Bar Graphs (BARS)'

dislin.scrmod ('revers')
dislin.setpag ('da4p')
dislin.metafl ('cons')
dislin.disini ()
dislin.pagera ()
dislin.complx ()
dislin.ticks  (1, 'x')
dislin.intax  ()
dislin.axslen (1600, 700)
dislin.titlin (ctit, 3)

cbuf = ' '
dislin.legini (cbuf, 3, 8)
dislin.leglin (cbuf, 'FIRST', 1)
dislin.leglin (cbuf, 'SECOND', 2)
dislin.leglin (cbuf, 'THIRD', 3)
dislin.legtit (' ')
dislin.shdpat (5)

for i in range (0, 3) :
  if i > 0 :
    dislin.labels ('none','x')

  dislin.axspos (300, nya-i*800)
  dislin.graf (0., 10., 0., 1., 0., 5., 0., 1.)

  if i == 0:
    dislin.bargrp (3, 0.15)
    dislin.color  ('red')
    dislin.bars   (x, y, y1, 9)
    dislin.color  ('green')
    dislin.bars   (x, y, y2, 9)
    dislin.color  ('blue')
    dislin.bars   (x, y, y3, 9)
    dislin.color  ('fore')
    dislin.reset  ('bargrp')
  elif i == 1:
    dislin.height (30)
    dislin.labels ('delta','bars')
    dislin.labpos ('center','bars')
    dislin.color  ('red')
    dislin.bars   (x, y, y1, 9)
    dislin.color  ('green')
    dislin.bars   (x, y1, y2, 9)
    dislin.color  ('blue')
    dislin.bars   (x, y2, y3, 9)
    dislin.color  ('fore')
    dislin.reset  ('height') 
  elif i == 2:
    dislin.labels ('second', 'bars')
    dislin.labpos ('outside', 'bars')
    dislin.color  ('red')
    dislin.bars   (x, y, y1, 9)
    dislin.color  ('fore')

  if i != 2:
    dislin.legend (cbuf,7)

  if i == 2:
    dislin.height (50)
    dislin.title  ()

  dislin.endgrf ()

dislin.disfin ()

Pie Charts / Python

#!/usr/bin/env python
import dislin

xray = [1., 2.5, 2., 2.7, 1.8]

ctit = 'Pie Charts (PIEGRF)'

dislin.scrmod ('revers')
dislin.setpag ('da4p')
dislin.metafl ('cons')
dislin.disini ()
dislin.pagera ()
dislin.complx ()
dislin.chnpie ('BOTH')

dislin.axslen (1600, 1000)
dislin.titlin (ctit, 2)

cbuf = ' '
dislin.legini (cbuf, 5, 8)
dislin.leglin (cbuf, 'FIRST',  1)
dislin.leglin (cbuf, 'SECOND', 2)
dislin.leglin (cbuf, 'THIRD',  3)
dislin.leglin (cbuf, 'FOURTH', 4)
dislin.leglin (cbuf, 'FIFTH',  5)

# Selecting shading patterns
dislin.patcyc (1, 7)
dislin.patcyc (2, 4)
dislin.patcyc (3, 13)
dislin.patcyc (4, 3)
dislin.patcyc (5, 5)

dislin.axspos (250, 2800)
dislin.piegrf (cbuf, 1, xray, 5)
dislin.endgrf ()

dislin.axspos (250, 1600)
dislin.labels ('DATA', 'PIE')
dislin.labpos ('EXTERNAL', 'PIE')
dislin.piegrf (cbuf, 1, xray, 5)

dislin.height (50)
dislin.title  ()
dislin.disfin ()

3-D Bar Graph / 3-D Pie Chart / Python

#!/usr/bin/env python
import dislin

xray  = [2., 4., 6., 8., 10.]
y1ray = [0., 0., 0., 0., 0.]
y2ray = [3.2, 1.5, 2.0, 1.0, 3.0]

ic1ray  = [50, 150, 100, 200, 175]
ic2ray  = [50, 150, 100, 200, 175]

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.hwfont ()

dislin.titlin ('3-D Bar Graph / 3-D Pie Chart', 2)
dislin.htitle (40)

dislin.shdpat (16)
dislin.axslen (1500, 1000)
dislin.axspos (300, 1400)

dislin.barwth (0.5)
dislin.bartyp ('3dvert')
dislin.labels ('second', 'bars')
dislin.labpos ('outside', 'bars')
dislin.labclr (255, 'bars')
dislin.graf   (0., 12., 0., 2., 0., 5., 0., 1.)
dislin.title  ()
dislin.color  ('red')
dislin.bars   (xray, y1ray, y2ray, 5)
dislin.endgrf ()

dislin.shdpat (16)
dislin.labels ('data', 'pie')
dislin.labclr (255, 'pie')
dislin.chnpie ('none')
dislin.pieclr (ic1ray, ic2ray, 5)
dislin.pietyp ('3d')
dislin.axspos (300, 2700)
cbuf = ' '
dislin.piegrf (cbuf, 0, y2ray, 5)  
dislin.disfin ()

3-D Bars / BARS3D / Python

#!/usr/bin/env python
import dislin

n = 18

xray  =  [1., 3., 8., 1.5, 9., 6.3, 5.8, 2.3, 8.1, 3.5,
          2.2, 8.7, 9.2, 4.8, 3.4, 6.9, 7.5, 3.8]
yray  =  [5., 8., 3.5, 2., 7., 1.,4.3, 7.2, 6.0, 8.5,
          4.1, 5.0, 7.3, 2.8, 1.6, 8.9, 9.5, 3.2]
z1ray =  [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
          0., 0., 0., 0., 0., 0., 0., 0.]
z2ray =  [4., 5., 3., 2., 3.5, 4.5, 2., 1.6, 3.8, 4.7,
          2.1, 3.5, 1.9, 4.2, 4.9, 2.8, 3.6, 4.3]
icray =  [30, 30, 30, 30, 30, 30, 100, 100, 100, 100,
         100, 100, 170, 170, 170, 170, 170, 170]

xwray = range (n)
ywray = range (n)
for i in range (0,n):
  xwray[i] = 0.5
  ywray[i] = 0.5

dislin.scrmod ('revers')
dislin.metafl ('xwin')
dislin.setpag ('da4p')
dislin.disini ()
dislin.hwfont ()
dislin.pagera ()

dislin.axspos (200, 2600)
dislin.axslen (1800, 1800)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')
dislin.name   ('Z-axis', 'Z')

dislin.titlin ('3-D Bars / BARS3D',3)
dislin.labl3d ('hori')

dislin.graf3d (0.,10.,0.,2.,0.,10.,0.,2.,0.,5.,0.,1.)
dislin.grid3d (1,1, 'bottom')

dislin.bars3d (xray, yray, z1ray, z2ray, xwray, ywray, icray, n)

cbuf = ' '
dislin.legini (cbuf, 3, 20)
dislin.legtit (' ')
dislin.legpos (1350, 1150)
dislin.leglin (cbuf, 'First', 1)
dislin.leglin (cbuf, 'Second', 2)
dislin.leglin (cbuf, 'Third', 3)
dislin.legend (cbuf, 3)

dislin.height (50)
dislin.title ()
dislin.disfin ()

Shading Patterns / Python

#!/usr/bin/env python
import dislin

ix  = [0, 300, 300,   0]
iy  = [0,   0, 400, 400]
ixp = [0, 0, 0, 0]
iyp = [0, 0, 0, 0]

ctit = 'Shading Patterns (AREAF)'

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.disini ()
dislin.setvlt ('small')
dislin.pagera ()
dislin.complx ()

dislin.height (50)
nl = dislin.nlmess (ctit)
dislin.messag (ctit, (2970 - nl)/2, 200)

nx0 = 335
ny0 = 350

iclr = 0
for i in range (0, 3):
  ny = ny0 + i * 600
  for j in range (0, 6):
    nx = nx0 + j * 400
    ii = i * 6 + j
    dislin.shdpat (ii)
    iclr = iclr + 1
    dislin.setclr (iclr)
    for k in range (0, 4):
      ixp[k] = ix[k] + nx
      iyp[k] = iy[k] + ny

    dislin.areaf (ixp, iyp, 4)
    nl = dislin.nlnumb (ii, -1)
    nx = nx + (300 - nl) / 2
    dislin.color ('foreground')
    dislin.number (ii, -1, nx, ny + 460) 

dislin.disfin ()

3-D Colour Plot / Python

#! /usr/bin/env python
import math
import dislin

ctit1 = '3-D  Colour Plot of the Function'
ctit2 = 'F(X,Y) = 2 * SIN(X) * SIN (Y)'

n = 50
m = 50
zmat = range(n*m)

fpi  = 3.1415927 / 180.
stepx = 360. / (n - 1)
stepy = 360. / (m - 1)

for i in range (0, n):
  x = i * stepx
  for j in range (0, m):
    y = j * stepy
    zmat[i*m+j] = 2 * math.sin(x * fpi) * math.sin(y * fpi)

dislin.scrmod ('revers')
dislin.metafl ('xwin')
dislin.disini ()
dislin.pagera ()
dislin.hwfont ()

dislin.titlin (ctit1, 1)
dislin.titlin (ctit2, 3)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')
dislin.name   ('Z-axis', 'Z')

dislin.intax  ()
dislin.autres (n, m)
dislin.axspos (300, 1850)
dislin.ax3len (2200, 1400, 1400)

dislin.graf3   (0., 360., 0., 90., 0., 360., 0., 90.,
                -2., 2., -2., 1.)
dislin.crvmat (zmat, n, m, 1, 1)
dislin.height (50)
dislin.title  ()
dislin.disfin ()

Surface Plot / Python

#! /usr/bin/env python
import math
import dislin

ctit1 = 'Surface Plot of the Function'
ctit2 = 'F(X,Y) = 2 * SIN(X) * SIN (Y)'

n = 50
m = 50
zmat = range(n*m)

fpi  = 3.1415927 / 180.
stepx = 360. / (n - 1)
stepy = 360. / (m - 1)

for i in range (0, n):
  x = i * stepx
  for j in range (0, m):
    y = j * stepy
    zmat[i*m+j] = 2 * math.sin(x * fpi) * math.sin(y * fpi)

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.titlin (ctit1, 2)
dislin.titlin (ctit2, 4)

dislin.axspos (200, 2600)
dislin.axslen (1800, 1800)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')
dislin.name   ('Z-axis', 'Z')

dislin.view3d (-5., -5., 4., 'ABS')
dislin.graf3d  (0., 360., 0., 90., 0., 360., 0., 90.,
                -3., 3., -3., 1.)
dislin.height (50)
dislin.title  ()

dislin.color  ('green')
dislin.surmat (zmat, n, m, 1, 1)
dislin.disfin ()

Shaded Surface Plot / Python

#! /usr/bin/env python
import math
import dislin

ctit1 = 'Shaded Surface Plot'
ctit2 = 'F(X,Y) = 2 * SIN(X) * SIN (Y)'

n = 50
m = 50
zmat = range(n*m)
xray = range(n)
yray = range(m)

fpi  = 3.1415927 / 180.
stepx = 360. / (n - 1)
stepy = 360. / (m - 1)

for i in range (0, n):
  x = i * stepx
  xray[i] = x
  for j in range (0, m):
    y = j * stepy
    yray[j] = y
    zmat[i*m+j] = 2 * math.sin(x * fpi) * math.sin(y * fpi)

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.titlin (ctit1, 2)
dislin.titlin (ctit2, 4)

dislin.axspos (200, 2600)
dislin.axslen (1800, 1800)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')
dislin.name   ('Z-axis', 'Z')

dislin.view3d (-5., -5., 4., 'ABS')
dislin.graf3d  (0., 360., 0., 90., 0., 360., 0., 90.,
                -3., 3., -3., 1.)
dislin.height (50)
dislin.title  ()

dislin.shdmod ('smooth', 'surface')
dislin.surshd (xray, n, yray, m, zmat)
dislin.disfin ()

Contour Plot / Python

#! /usr/bin/env python
import math
import dislin

ctit1 = 'Contour Plot'
ctit2 = 'F(X,Y) = 2 * SIN(X) * SIN (Y)'

n = 50
m = 50

xray = range (n)
yray = range (m)
zmat = range (n*m)

fpi  = 3.1415927 / 180.
stepx = 360. / (n - 1)
stepy = 360. / (m - 1)

for i in range (0, n):
  xray[i] = xray[i] * stepx

for i in range (0, m):
  yray[i] = yray[i] * stepy

for i in range (0, n):
  x = xray[i] * fpi
  for j in range (0, m):
    y = yray[j] * fpi
    zmat[i*m+j] = 2 * math.sin(x) * math.sin(y)

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.titlin (ctit1, 1)
dislin.titlin (ctit2, 3)

dislin.intax  ()
dislin.axspos (450, 2650)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')

dislin.graf   (0., 360., 0., 90., 0., 360., 0., 90.)
dislin.height (50)
dislin.title  ()

dislin.height (30)
for i in range (0, 9):
  zlev = -2. + i * 0.5
  if i == 4:
    dislin.labels ('NONE', 'CONTUR')
  else:
    dislin.labels ('FLOAT', 'CONTUR')

  dislin.setclr ((i+1) * 28)
  dislin.contur (xray, n, yray, m, zmat, zlev)

dislin.disfin ()

Shaded Contour Plot / Python

#! /usr/bin/env python
import math
import dislin

ctit1 = 'Shaded Contour Plot'
ctit2 = 'F(X,Y) = (X[2$ - 1)[2$ + (Y[2$ - 1)[2$'

n = 50
m = 50
xray = range (n)
yray = range (m)
zlev = range (12)
zmat = range (n*m)

stepx = 1.6 / (n - 1)
stepy = 1.6 / (m - 1)

for i in range (0, n):
  xray[i] = xray[i] * stepx

for i in range (0, m):
  yray[i] = yray[i] * stepy

for i in range (0, n):
  x = xray[i] * xray[i] - 1.
  x = x * x
  for j in range (0, m):
    y = yray[j] * yray[j] - 1.
    zmat[i*m+j] = x + y * y

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')

dislin.disini ()
dislin.pagera ()
dislin.complx ()
dislin.mixalf ()

dislin.titlin (ctit1, 1)
dislin.titlin (ctit2, 3)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')

dislin.axspos (450, 2670)
dislin.shdmod ('poly', 'contur')
dislin.graf   (0., 1.6, 0., 0.2, 0., 1.6, 0., 0.2)

for i in range (0, 12):
  zlev[11-i] = 0.1 + i * 0.1

dislin.conshd (xray, n, yray, m, zmat, zlev, 12)

dislin.height (50)
dislin.title  ()

dislin.disfin ()

Shaded Surface / Contour Plot / Python

#! /usr/bin/env python
import math
import dislin

ctit1 = 'Shaded Surface / Contour Plot'
ctit2 = 'F(X,Y) = 2 * SIN(X) * SIN (Y)'

n = 50
m = 50
nlev = 20

zmat = range(n*m)
xray = range(n)
yray = range(m)
zlev = range(nlev)

fpi  = 3.1415927 / 180.
stepx = 360. / (n - 1)
stepy = 360. / (m - 1)

for i in range (0, n):
  x = i * stepx
  xray[i] = x
  for j in range (0, m):
    y = j * stepy
    yray[j] = y
    zmat[i*m+j] = 2 * math.sin(x * fpi) * math.sin(y * fpi)

dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.hwfont ()

dislin.titlin (ctit1, 2)
dislin.titlin (ctit2, 4)

dislin.axspos (200, 2600)
dislin.axslen (1800, 1800)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')
dislin.name   ('Z-axis', 'Z')

dislin.graf3d (0., 360., 0., 90., 0., 360., 0., 90.,
               -2., 2., -2., 1.)
dislin.height (50)
dislin.title  ()

dislin.grfini (-1., -1., -1., 1., -1., -1., 1., 1., -1.)
dislin.nograf ()
dislin.graf (0., 360., 0., 90., 0., 360., 0., 90.)
  
step = 4. / nlev
for i in range (0, nlev):
   zlev[i] = -2.0 + i * step 

dislin.conshd (xray, n, yray, n, zmat, zlev, nlev)

dislin.box2d ()
dislin.reset ('nograf')
dislin.grffin ()

dislin.shdmod ('smooth', 'surface')
dislin.surshd (xray, n, yray, m, zmat)
dislin.disfin ()

Spheres and Tubes / Python

#! /usr/bin/env python
import dislin

x = [10., 20., 10., 20., 5., 15., 25., 5., 15., 25., 
      5., 15., 25., 10., 20., 10., 20.]
y = [10., 10., 20., 20., 5., 5., 5., 15., 15., 15.,
      25., 25., 25., 10., 10., 20., 20.]
z = [5., 5., 5., 5., 15., 15., 15., 15., 15., 15.,
    15., 15., 15., 25., 25., 25., 25.]  
idx = [1, 2, 1, 3, 3, 4, 2, 4, 5, 6, 6, 7, 8, 9, 9, 10,
      11, 12, 12, 13,  5, 8, 8, 11, 6, 9, 9, 12, 7, 10,
      10, 13,  14, 15, 16, 17, 14, 16, 15, 17,
       1, 5, 2, 7, 3, 11, 4, 13, 5, 14, 7, 15, 11, 16, 13, 17]

dislin.setpag ('da4p')
dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.disini ()
dislin.pagera ()
dislin.hwfont ()
dislin.light ('on')
dislin.matop3 (0.02, 0.02, 0.02, 'specular')

dislin.clip3d ('none')
dislin.axspos (0, 2500)
dislin.axslen (2100, 2100)

dislin.htitle (50)
dislin.titlin ('Spheres and Tubes', 4)

dislin.name ('X-axis', 'x')
dislin.name ('Y-axis', 'y')
dislin.name ('Z-axis', 'z')

dislin.labdig (-1, 'xyz')
dislin.labl3d ('hori')
dislin.graf3d (0., 30., 0., 5., 0., 30., 0., 5., 0., 30., 0., 5.)
dislin.title ()

dislin.shdmod ('smooth', 'surface')

iret = dislin.zbfini()
dislin.matop3 (1.0, 0.0, 0.0, 'diffuse')
for i in range (0, 17):
  dislin.sphe3d (x[i], y[i], z[i], 2.0, 50, 25)

dislin.matop3 (0.0, 1.0, 0.0, 'diffuse')
for i in range (0, 28):
  j = 2 * i
  j1 = idx[j] - 1
  j2 = idx[j+1] - 1
  dislin.tube3d (x[j1], y[j1], z[j1], 
                 x[j2], y[j2], z[j2], 0.5, 5, 5) 

dislin.zbffin ()
dislin.disfin ()

Some Solids / Python

#! /usr/bin/env python
import dislin

dislin.setpag ('da4p')
dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.disini ()
dislin.pagera ()
dislin.hwfont ()
dislin.light ('on')
dislin.litop3(1,0.5,0.5,0.5,'ambient')

dislin.clip3d ('none')
dislin.axspos (0, 2500)
dislin.axslen (2100, 2100)

dislin.htitle (60)
dislin.titlin ('Some Solids', 4)

dislin.nograf ()
dislin.graf3d (-5., 5., -5., 2., -5., 5., -5., 2., -5., 5., -5., 2.)
dislin.title ()
 
dislin.shdmod ('smooth', 'surface')
iret = dislin.zbfini()
dislin.matop3 (1.0, 0.5, 0.0, 'diffuse')
dislin.tube3d (-3., -3., 8.0, 2., 3., 5.5, 1., 40, 20) 

dislin.rot3d (-60., 0., 0.) 
dislin.matop3 (1.0, 0.0, 1.0, 'diffuse')
dislin.setfce ('bottom')
dislin.matop3 (1.0, 0.0, 0.0, 'diffuse')
dislin.cone3d (-3., -3., 3.5, 2., 3., 3., 40, 20)
dislin.setfce ('top')

dislin.rot3d (0., 0., 0.) 
dislin.matop3 (0.0, 1.0, 1.0, 'diffuse')
dislin.plat3d (4., 4., 3., 3., 'icos')

dislin.rot3d (0., 0., 0.) 
dislin.matop3 (1.0, 1.0, 0.0, 'diffuse')
dislin.sphe3d (0., 0., 0., 3., 40, 20)

dislin.rot3d (0., 0., -20.) 
dislin.matop3 (0.0, 0.0, 1.0, 'diffuse')
dislin.quad3d (-4., -4., -3., 3., 3., 3.)

dislin.rot3d (0., 0., 30.) 
dislin.matop3 (1.0, 0.3, 0.3, 'diffuse')
dislin.pyra3d (-2., -5., -10., 3., 5., 5., 4)

dislin.rot3d (0., 0., 0.) 
dislin.matop3 (1.0, 0.0, 0.0, 'diffuse')
dislin.torus3d (7., -3., -2., 1.5, 3.5, 1.5, 0., 360., 40, 20)
dislin.rot3d (0., 90., 0.) 

dislin.matop3 (0.0, 1.0, 0.0, 'diffuse')
dislin.torus3d (7., -5., -2., 1.5, 3.5, 1.5, 0., 360., 40, 20)
dislin.zbffin ()
dislin.disfin ()

Map Plot / Python

#! /usr/bin/env python
import dislin

dislin.scrmod ('revers')
dislin.metafl ('xwin')
dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.axspos (400, 1850)
dislin.axslen (2400, 1400)

dislin.name   ('Longitude', 'X')
dislin.name   ('Latitude',  'Y')
dislin.titlin ('World Coastlines and Lakes', 3)

dislin.labels ('MAP', 'XY')
dislin.digits (-1, 'XY')
dislin.grafmp (-180., 180., -180., 90., -90., 90., -90., 30.)

dislin.gridmp (1, 1)
dislin.color  ('green')
dislin.world  ()

dislin.color  ('foreground')
dislin.height (50)
dislin.title  ()
dislin.disfin ()

Tex Instructions for Mathematical Formulas / Python

#! /usr/bin/env python
import math
import dislin
  
dislin.scrmod ('revers')
dislin.metafl ('cons')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.complx ()
dislin.height (40)

cstr = 'TeX Instructions for Mathematical Formulas'
nl = dislin.nlmess (cstr)
dislin.messag (cstr, (2100 - nl)/2, 100)
  
dislin.texmod ('on')
dislin.messag ('$\\frac{1}{x+y}$', 150, 400)
dislin.messag ('$\\frac{a^2 - b^2}{a+b} = a - b$', 1200, 400)
  
dislin.messag ('$r = \\sqrt{x^2 + y^2}', 150, 700)
dislin.messag ('$\\cos \\phi = \\frac{x}{\\sqrt{x^2 + y^2}}$', 1200, 700)

dislin.messag ('$\\Gamma(x) = \\int_0^\\infty e^{-t}t^{x-1}dt$', 150, 1000)
dislin.messag ('$\\lim_{x \\to \\infty} (1 + \\frac{1}{x})^x = e$', 1200, 1000)

dislin.messag ('$\\mu = \\sum_{i=1}^n x_i p_i$', 150, 1300)
dislin.messag ('$\\mu = \\int_{-\\infty}^ \\infty x f(x) dx$', 1200, 1300)

dislin.messag ('$\\overline{x} = \\frac{1}{n} \\sum_{i=1}^n x_i$', 150, 1600)
dislin.messag ('$s^2 = \\frac{1}{n-1} \\sum_{i=1}^n (x_i - \\overline{x})^2$',
               1200, 1600)

dislin.messag ('$\\sqrt[n]{\\frac{x^n - y^n}{1 + u^{2n}}}$', 150, 1900)  
dislin.messag ('$\\sqrt[3]{-q + \\sqrt{q^2 + p^3}}$', 1200, 1900)

dislin.messag ('$\\int \\frac{dx}{1+x^2} = \\arctan x + C$', 150, 2200)
dislin.messag ('$\\int \\frac{dx}{\\sqrt{1+x^2}} = {\\rm arsinh} x + C$',
               1200, 2200)

dislin.messag ('$\\overline{P_1P_2} = \\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$',
               150,2500)
dislin.messag ('$x = \\frac{x_1 + \\lambda x_2}{1 + \\lambda}$', 1200, 2500)
dislin.disfin ()

Web Example / Python

#! /usr/bin/env python
import math
import sys
import dislin

ctit1 = 'Surface Plot of the Function'
ctit2 = 'F(X,Y) = 2 * SIN(X) * SIN (Y)'

n = 50
m = 50
zmat = range(n*m)

fpi  = 3.1415927 / 180.
stepx = 360. / (n - 1)
stepy = 360. / (m - 1)

for i in range (0, n):
  x = i * stepx
  for j in range (0, m):
    y = j * stepy
    zmat[i*m+j] = 2 * math.sin(x * fpi) * math.sin(y * fpi)


dislin.scrmod ('revers')
dislin.metafl ('virt')
dislin.setpag ('da4p')
dislin.disini ()
dislin.pagera ()
dislin.complx ()

dislin.titlin (ctit1, 2)
dislin.titlin (ctit2, 4)

dislin.axspos (200, 2600)
dislin.axslen (1800, 1800)

dislin.name   ('X-axis', 'X')
dislin.name   ('Y-axis', 'Y')
dislin.name   ('Z-axis', 'Z')

dislin.view3d (-5., -5., 4., 'ABS')
dislin.graf3d  (0., 360., 0., 90., 0., 360., 0., 90.,
                -3., 3., -3., 1.)
dislin.height (50)
dislin.title  ()

dislin.color  ('green')
dislin.surmat (zmat, n, m, 1, 1)

[buf, n] = dislin.rbfpng (0)
[buf, n] = dislin.rbfpng (n)
dislin.unit (0)
dislin.disfin ()

sys.stdout.write("Content-type: image/png\n\n")
sys.stdout.write(buf)
 
loading content