## DISLIN Examples / Go

#### Demonstration of CURVE / Go

package main

import "dislin"
import "math"

func main () {
const n int = 100
var step, fpi, x float64
var xray, y1ray, y2ray  [n]float64

step = 360.0 / float64 (n - 1)
fpi  = 3.1415926 / 180.0
for i:= 0; i < n; i++ {
xray[i] = float64 (i) * step
x = xray[i] * fpi
y1ray[i] = math.Sin (x)
y2ray[i] = math.Cos (x)
}

dislin.Metafl ("xwin")
dislin.Scrmod ("reverse")
dislin.Disini ()
dislin.Pagera ()
dislin.Complx ()

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)

dislin.Axspos (450, 1800)
dislin.Axslen (2200, 1200)

ic := dislin.Intrgb (0.95, 0.95, 0.95)
dislin.Axsbgd (ic)

dislin.Graf   (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 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  (&xray[0], &y1ray[0], n)
dislin.Color  ("green")
dislin.Curve  (&xray[0], &y2ray[0], n)
dislin.Disfin ()
}


#### Polar Plots / Go

package main

import "dislin"
import "math"

func main () {
const n int = 300
const m int = 10
var x1, y1  [n]float64
var x2, y2  [m]float64

pi := 3.1415926
f := pi / 180.0
step := 360.0 / float64 (n - 1)

for i:= 0; i < n; i++ {
a := (float64 (i) * step) * f
y1[i] = a
x1[i] = math.Sin (5 * a)
}

for i:= 0; i < m; i++ {
x2[i] = float64 (i + 1)
y2[i] = float64 (i + 1)
}

dislin.Setpag ("da4p")
dislin.Scrmod ("revers")
dislin.Metafl ("cons")
dislin.Disini ()
dislin.Complx ()
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.0, 0.2, 0.0, 30.0);
dislin.Color  ("blue")
dislin.Curve  (&x1[0], &y1[0], 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, 0.0, 2.0, 0.0, 30.0)
dislin.Barwth (-5.0)
dislin.Polcrv ("FBARS")
dislin.Color  ("blue")
dislin.Curve  (&x2[0], &y2[0], m)

dislin.Disfin ()
}



#### Symbols / Go

package main

import "dislin"

func main () {
var ctit = "Symbols"
var nl, ny, nxp int

dislin.Setpag ("da4p")
dislin.Metafl ("cons")
dislin.Disini ()
dislin.Complx ()
dislin.Pagera ()

dislin.Paghdr ("H. Michels   (", ")", 2, 0)

dislin.Height (60)
nl = dislin.Nlmess (ctit)
dislin.Messag (ctit,  (2100 - nl) / 2, 200)

dislin.Height (50)
dislin.Hsymbl (120)

ny = 150
for i:=0; i < 22; i++ {
if  (i % 4) == 0 {
ny = ny + 400
nxp = 550
} else {
nxp = nxp + 350
}

x := float64 (i)
nl = dislin.Nlnumb (x, -1)
dislin.Number (x, -1, nxp - nl/2, ny + 150)
dislin.Symbol (i, nxp, ny)
}
dislin.Disfin ()
}



#### Interpolation Methods / Go

package main

import "dislin"

func main  () {
ctit := "Interpolation Methods"
cpol := [6]string{"SPLINE", "STEM", "BARS", "STAIRS", "STEP", "LINEAR"}
xray := [16]float64{0.0, 1.0, 3.0, 4.5, 6.0, 8.0, 9.0, 11.0, 12.0, 12.5,
13.0, 15.0, 16.0, 17.0, 19.0, 20.0}
yray := [16]float64{2.0, 4.0, 4.5, 3.0, 1.0, 7.0, 2.0, 3.0, 5.0, 2.0, 2.5,
2.0, 4.0, 6.0, 5.5, 4.0}

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, 350)
dislin.Setgrf ("LINE", "LINE", "LINE", "LINE")

nya := 2700
for i:=0; i < 6; i++ {
dislin.Axspos (350, nya - i * 350)
dislin.Polcrv (cpol[i])
dislin.Marker (0)
dislin.Graf (0.0, 20.0, 0.0, 5.0, 0.0, 10.0, 0.0, 5.0)
nx := dislin.Nxposn (1.0)
ny := dislin.Nyposn (8.0)
dislin.Messag (cpol[i], nx, ny)
dislin.Curve (&xray[0], &yray[0], 16)

if i == 5 {
dislin.Height (50)
dislin.Title ()
}

dislin.Endgrf ()
}

dislin.Disfin ()
}


#### Bar Graphs / Go

package main
import "dislin"

func main  () {
x  := [9]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}
y  := [9]float64{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
y1 := [9]float64{1.0, 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.10}
y2 := [9]float64{2.0, 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8}
y3 := [9]float64{4.0, 3.5, 4.5, 3.7, 4.0, 2.9, 3.0, 3.2, 2.6}
var cbuf [24]int8

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)

dislin.Legini (&cbuf[0], 3, 8)
dislin.Leglin (&cbuf[0], "FIRST", 1)
dislin.Leglin (&cbuf[0], "SECOND", 2)
dislin.Leglin (&cbuf[0], "THIRD", 3)
dislin.Legtit (" ")
dislin.Shdpat (5)

for i:= 0; i < 3; i++ {
if i > 0 {
dislin.Labels ("none", "x")
}
dislin.Axspos (300, nya - i * 800)
dislin.Graf   (0.0, 10.0, 0.0, 1.0, 0.0, 5.0, 0.0, 1.0)

if i == 0 {
dislin.Bargrp (3, 0.15)
dislin.Color  ("red")
dislin.Bars   (&x[0], &y[0], &y1[0], 9)
dislin.Color  ("green")
dislin.Bars   (&x[0], &y[0], &y2[0], 9)
dislin.Color  ("blue")
dislin.Bars   (&x[0], &y[0], &y3[0], 9)
dislin.Color  ("fore")
dislin.Reset  ("bargrp")
} else if i == 1 {
dislin.Height (30)
dislin.Labels ("delta", "bars")
dislin.Labpos ("center", "bars")
dislin.Color  ("red")
dislin.Bars   (&x[0], &y[0], &y1[0], 9)
dislin.Color  ("green")
dislin.Bars   (&x[0], &y1[0], &y2[0], 9)
dislin.Color  ("blue")
dislin.Bars   (&x[0], &y2[0], &y3[0], 9)
dislin.Color  ("fore")
dislin.Reset  ("height")
} else if i == 2 {
dislin.Labels ("second", "bars")
dislin.Labpos ("outside", "bars")
dislin.Color  ("red")
dislin.Bars   (&x[0], &y[0], &y1[0], 9)
dislin.Color  ("fore")
}

if i != 2 {
dislin.Legend (&cbuf[0], 7)
}

if i == 2 {
dislin.Height (50)
dislin.Title  ()
}
dislin.Endgrf ()
}

dislin.Disfin ()
}


#### Pie Charts / Go

package main
import "dislin"

func main  () {
var cbuf [14]int8
xray  := [5]float64{1.0, 2.5, 2.0, 2.7, 1.8}

ctit := "Pie Charts(PIEGRF)"

dislin.Setpag ("da4p")
dislin.Metafl ("cons")
dislin.Disini ()
dislin.Pagera ()
dislin.Complx ()
dislin.Chnpie ("BOTH")

dislin.Axslen (1600, 1000)
dislin.Titlin (ctit, 2)

dislin.Legini (&cbuf[0], 5, 8)
dislin.Leglin (&cbuf[0], "FIRST",  1)
dislin.Leglin (&cbuf[0], "SECOND", 2)
dislin.Leglin (&cbuf[0], "THIRD",  3)
dislin.Leglin (&cbuf[0], "FOURTH", 4)
dislin.Leglin (&cbuf[0], "FIFTH",  5)

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[0], 1, &xray[0], 5)
dislin.Endgrf ()

dislin.Axspos (250, 1600)
dislin.Labels ("DATA", "PIE")
dislin.Labpos ("EXTERNAL", "PIE")
dislin.Piegrf (&cbuf[0], 1, &xray[0], 5)

dislin.Height (50)
dislin.Title  ()
dislin.Disfin ()
}


#### 3-D Bar Graph / 3-D Pie Chart / Go

package main
import "dislin"

func main  () {
xray  := [5]float64{2.0, 4.0, 6.0, 8.0, 10.0}
y1ray := [5]float64{0.0, 0.0, 0.0, 0.0, 0.0}
y2ray := [5]float64{3.2, 1.5, 2.0, 1.0, 3.0}
ic1ray  := [5]int32{50, 150, 100, 200, 175}
ic2ray  := [5]int32{50, 150, 100, 200, 175}
var cbuf [10]int8

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.0, 12.0, 0.0, 2.0, 0.0, 5.0, 0.0, 1.0)
dislin.Title  ()
dislin.Color  ("red")
dislin.Bars   (&xray[0], &y1ray[0], &y2ray[0], 5)
dislin.Endgrf ()

dislin.Shdpat (16)
dislin.Labels ("data", "pie")
dislin.Labclr (255, "pie")
dislin.Chnpie ("none")
dislin.Pieclr (&ic1ray[0], &ic2ray[0], 5)
dislin.Pietyp ("3d")
dislin.Axspos (300, 2700)
dislin.Piegrf (&cbuf[0], 0, &y2ray[0], 5)
dislin.Disfin ()
}


#### 3-D Bars / BARS3D / Go

package main
import "dislin"

func main  () {
const n int = 18

xray  := [n]float64{1.0, 3.0, 8.0, 1.5, 9.0, 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  := [n]float64{5.0, 8.0, 3.5, 2.0, 7.0, 1.0, 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 := [n]float64{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
z2ray := [n]float64{4.0, 5.0, 3.0, 2.0, 3.5, 4.5, 2.0, 1.6, 3.8, 4.7,
2.1, 3.5, 1.9, 4.2, 4.9, 2.8, 3.6, 4.3}
icray := [n]int32{30, 30, 30, 30, 30, 30, 100, 100, 100, 100,
100, 100, 170, 170, 170, 170, 170, 170}
var xwray, ywray [n]float64
var cbuf [60]int8

for i:=0; i < n; i++ {
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.0,10.0,0.0,2.0,0.0,10.0,0.0,2.0,0.0,5.0,0.0,1.0)
dislin.Grid3d (1, 1, "bottom")

dislin.Bars3d (&xray[0], &yray[0], &z1ray[0],
&z2ray[0], &xwray[0], &ywray[0], &icray[0], n)

dislin.Legini (&cbuf[0], 3, 20)
dislin.Legtit (" ")
dislin.Legpos (1350, 1150)
dislin.Leglin (&cbuf[0], "First", 1)
dislin.Leglin (&cbuf[0], "Second", 2)
dislin.Leglin (&cbuf[0], "Third", 3)
dislin.Legend (&cbuf[0], 3)

dislin.Height (50)
dislin.Title  ()
dislin.Disfin ()
}


package main
import "dislin"

func main  () {
ix  := [4]int32{0, 300, 300,   0}
iy  := [4]int32{0,   0, 400, 400}
ixp := [4]int32{0, 0, 0, 0}
iyp := [4]int32{0, 0, 0, 0}

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 := 0; i < 3; i++ {
ny := ny0 + i * 600

for j := 0; j < 6; j++ {
nx := nx0 + j * 400
ii := i * 6 + j
dislin.Shdpat (ii)
iclr = iclr + 1
iclr = iclr % 8
if iclr == 0 {
iclr = 8
}
dislin.Setclr (iclr)
for k := 0; k < 4; k++ {
ixp[k] = ix[k] + int32 (nx)
iyp[k] = iy[k] + int32 (ny)
}

dislin.Areaf (&ixp[0], &iyp[0], 4)
nl = dislin.Nlnumb (float64 (ii), -1)
nx = nx +  (300 - nl) / 2
dislin.Color ("foreground")
dislin.Number (float64 (ii), -1, nx, ny + 460)
}
}

dislin.Disfin ()
}


#### 3-D Colour Plot / Go

package main
import "dislin"
import "math"

func main () {
const n int = 50
const m int = 50
var zmat [n][m]float64

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

fpi   := 3.1415927 / 180.0
stepx := 360.0 / float64 (n - 1)
stepy := 360.0 / float64 (m - 1)

for i:= 0; i < n; i++ {
x := float64 (i) * stepx
for j:= 0; j < m; j++ {
y := float64 (j) * stepy
zmat[i][j] = 2 * math.Sin (x * fpi) * math.Sin (y * fpi)
}
}

dislin.Metafl ("xwin")
dislin.Disini ()
dislin.Pagera ()
dislin.Complx ()

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.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
-2.0, 2.0, -2.0, 1.0)
dislin.Crvmat (&zmat[0][0], n, m, 1, 1)
dislin.Height (50)
dislin.Title  ()
dislin.Disfin ()
}


#### Surface Plot / Go

package main
import "dislin"
import "math"

func main () {
const n int = 50
const m int = 50
var zmat [n][m]float64
ctit1 := "Surface Plot of the Function"
ctit2 := "F (X,Y) = 2 * SIN (X) * SIN (Y)"

fpi   := 3.1415927 / 180.0
stepx := 360.0 / float64 (n - 1)
stepy := 360.0 / float64 (m - 1)

for i:= 0; i < n; i++ {
x := float64 (i) * stepx
for j:= 0; j < m; j++ {
y := float64 (j) * stepy
zmat[i][j] = 2 * math.Sin (x * fpi) * math.Sin (y * fpi)
}
}

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.0, -5.0, 4.0, "ABS")
dislin.Graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
-3.0, 3.0, -3.0, 1.0)
dislin.Height (50)
dislin.Title  ()

dislin.Color ("green")
dislin.Surmat (&zmat[0][0], n, m, 1, 1)
dislin.Disfin ()
}


#### Shaded Surface Plot / Go

package main
import "dislin"
import "math"

func main () {
const n int = 50
const m int = 50
var zmat [n][m]float64
var xray [n]float64
var yray [m]float64

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

fpi  := 3.1415927 / 180.0
stepx := 360.0 / float64 (n - 1)
stepy := 360.0 / float64 (m - 1)

for i:= 0; i < n; i++ {
xray[i] = float64 (i) * stepx
}
for i:= 0; i < m; i++ {
yray[i] = float64 (i) * stepy
}

for i:= 0; i < n; i++ {
for j:= 0; j < m; j++ {
zmat[i][j] = 2 * math.Sin (xray[i] * fpi) *
math.Sin (yray[j] * fpi)
}
}

dislin.Metafl ("cons")
dislin.Scrmod ("revers")
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.0, -5.0, 4.0, "ABS")
dislin.Graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
-3.0, 3.0, -3.0, 1.0)
dislin.Height (50)
dislin.Title  ()

dislin.Shdmod ("smooth", "surface")
dislin.Surshd (&xray[0], n, &yray[0], n, &zmat[0][0])
dislin.Disfin ()
}


#### Contour Plot / Go

package main
import "dislin"
import "math"

func main () {
const n int = 50
const m int = 50
var xray [n] float64
var yray [m] float64
var zmat [n][m]float64

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

fpi   := 3.1415927 / 180.0
stepx := 360.0 / float64 (n - 1)
stepy := 360.0 / float64 (m - 1)

for i:= 0; i < n; i++ {
xray[i] = float64 (i) * stepx
}

for i:= 0; i < m; i++ {
yray[i] = float64 (i) * stepy
}

for i:= 0; i < n; i++ {
x := xray[i] * fpi
for j:= 0; j < m; j++ {
y := yray[j] * fpi
zmat[i][j] = 2 * math.Sin (x) * math.Sin (y)
}
}

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.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0)
dislin.Height (50)
dislin.Title  ()

dislin.Height (30)

for i:= 0; i < 8; i++ {
zlev := -2.0 + float64 (i) * 0.5

if i == 4 {
dislin.Labels ("NONE", "CONTUR")
} else {
dislin.Labels ("FLOAT", "CONTUR")
}

dislin.Setclr ( (i+1) * 28)
dislin.Contur (&xray[0], n, &yray[0], m, &zmat[0][0], zlev)
}
dislin.Disfin ()
}


#### Shaded Contour Plot / Go

package main
import "dislin"

func main () {
const n int = 50
const m int = 50
var xray [n] float64
var yray [m] float64
var zmat [n][m]float64
var zlev [12] float64

ctit2 := "F(X,Y) =(X[2$- 1)[2$ +(Y[2$- 1)[2$"

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

for i:= 0; i < n; i++ {
xray[i] = float64 (i) * stepx
}

for i:= 0; i < m; i++ {
yray[i] = float64 (i) * stepy
}

for i:= 0; i < n; i++ {
x := xray[i] * xray[i] - 1.0
x = x * x
for j:= 0; j < m; j++ {
y := yray[j] * yray[j] - 1.0
zmat[i][j] = x + y * y
}
}

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.0, 1.6, 0.0, 0.2, 0.0, 1.6, 0.0, 0.2)

for i:= 0; i < 12; i++ {
zlev[11-i] = 0.1 + float64 (i) * 0.1
}

dislin.Conshd (&xray[0], n, &yray[0], m, &zmat[0][0], &zlev[0], 12)

dislin.Height (50)
dislin.Title  ()
dislin.Disfin ()
}


#### Shaded Surface / Contour Plot / Go

package main
import "dislin"
import "math"

func main () {
const n int = 50
const m int = 50
const nlev int = 20
var zmat [n][m]float64
var xray [n]float64
var yray [m]float64
var zlev [nlev]float64

ctit1 := "Shaded Surface / Contour Plot"
ctit2 := "F(X,Y) = 2 * SIN(X) * SIN(Y)"
fpi  := 3.1415927 / 180.0
stepx := 360.0 / float64 (n - 1)
stepy := 360.0 / float64 (m - 1)

for i:= 0; i < n; i++ {
xray[i] = float64 (i) * stepx
}
for i:= 0; i < m; i++ {
yray[i] = float64 (i) * stepy
}

for i:= 0; i < n; i++ {
for j:= 0; j < m; j++ {
zmat[i][j] = 2 * math.Sin (xray[i] * fpi) *
math.Sin (yray[j] * 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.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
-2.0, 2.0, -2.0, 1.0)
dislin.Height (50)
dislin.Title  ()

dislin.Grfini (-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0)
dislin.Nograf ()
dislin.Graf   (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0)

step := 4.0 / float64 (nlev)
for i:= 0; i < nlev; i++ {
zlev[i] = -2.0 + float64 (i) * step
}
dislin.Conshd (&xray[0], n, &yray[0], n, &zmat[0][0], &zlev[0], nlev)

dislin.Box2d ();
dislin.Reset ("nograf");
dislin.Grffin ();

dislin.Shdmod ("smooth", "surface")
dislin.Surshd (&xray[0], n, &yray[0], m, &zmat[0][0])
dislin.Disfin ()
}


#### Spheres and Tubes / Go

package main
import "dislin"

func main  () {
x := [17]float64{10.0, 20.0, 10.0, 20.0, 5.0, 15.0, 25.0, 5.0, 15.0, 25.0,
5.0, 15.0, 25.0, 10.0, 20.0, 10.0, 20.0}
y := [17]float64{10.0, 10.0, 20.0, 20.0, 5.0, 5.0, 5.0, 15.0, 15.0, 15.0,
25.0, 25.0, 25.0, 10.0, 10.0, 20.0, 20.0}
z := [17]float64{5.0, 5.0, 5.0, 5.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0,
15.0, 15.0, 15.0, 25.0, 25.0, 25.0, 25.0}
idx := [56]int32{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.0, 30.0, 0.0, 5.0, 0.0, 30.0, 0.0, 5.0,
0.0, 30.0, 0.0, 5.0)
dislin.Title  ()

dislin.Shdmod ("smooth", "surface")

dislin.Zbfini ()
dislin.Matop3 (1.0, 0.0, 0.0, "diffuse")
for i:=0; i < 17; i++ {
dislin.Sphe3d (x[i], y[i], z[i], 2.0, 50, 25)
}

dislin.Matop3 (0.0, 1.0, 0.0, "diffuse")
for i:=0; i < 28; i++ {
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 / Go

package main
import "dislin"

func main  () {
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.0, 5.0, -5.0, 2.0, -5.0, 5.0, -5.0, 2.0,
-5.0, 5.0, -5.0, 2.0)
dislin.Title  ()

dislin.Shdmod ("smooth", "surface")
dislin.Zbfini ()
dislin.Matop3 (1.0, 0.5, 0.0, "diffuse")
dislin.Tube3d (-3.0, -3.0, 8.0, 2.0, 3.0, 5.5, 1.0, 40, 20)

dislin.Rot3d  (-60.0, 0.0, 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.0, -3.0, 3.5, 2.0, 3.0, 3.0, 40, 20)
dislin.Setfce ("top")

dislin.Rot3d  (0.0, 0.0, 0.0)
dislin.Matop3 (0.0, 1.0, 1.0, "diffuse")
dislin.Plat3d (4.0, 4.0, 3.0, 3.0, "icos")

dislin.Rot3d  (0.0, 0.0, 0.0)
dislin.Matop3 (1.0, 1.0, 0.0, "diffuse")
dislin.Sphe3d (0.0, 0.0, 0.0, 3.0, 40, 20)

dislin.Rot3d  (0.0, 0.0, -20.0)
dislin.Matop3 (0.0, 0.0, 1.0, "diffuse")
dislin.Quad3d (-4.0, -4.0, -3.0, 3.0, 3.0, 3.0)

dislin.Rot3d  (0.0, 0.0, 30.0)
dislin.Matop3 (1.0, 0.3, 0.3, "diffuse")
dislin.Pyra3d (-2.0, -5.0, -10.0, 3.0, 5.0, 5.0, 4)

dislin.Rot3d  (0.0, 0.0, 0.0)
dislin.Matop3 (1.0, 0.0, 0.0, "diffuse")
dislin.Torus3d (7.0, -3.0, -2.0, 1.5, 3.5, 1.5, 0.0, 360.0, 40, 20)
dislin.Rot3d  (0.0, 90.0, 0.0)

dislin.Matop3 (0.0, 1.0, 0.0, "diffuse")
dislin.Torus3d (7.0, -5.0, -2.0, 1.5, 3.5, 1.5, 0.0, 360.0, 40, 20)
dislin.Zbffin ()
dislin.Disfin ()
}


#### Map Plot / Go

package main
import "dislin"

func main  () {
dislin.Metafl ("cons")
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.Labdig (-1, "XY")
dislin.Grafmp (-180.0, 180.0, -180.0, 90.0, -90.0, 90.0, -90.0, 30.0)

dislin.Gridmp (1, 1)
dislin.Color ("green")
dislin.World ()

dislin.Color ("foreground")
dislin.Height (50)
dislin.Title ()

dislin.Disfin ()
}


#### Tex Instructions for Mathematical Formulas / Go

package main
import "dislin"

func main   () {
dislin.Scrmod ("revers")
dislin.Setpag ("da4p")
dislin.Metafl ("cons")
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 ()
}