-
Notifications
You must be signed in to change notification settings - Fork 6
/
gpdemo.ijs
82 lines (70 loc) · 1.73 KB
/
gpdemo.ijs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
NB. gnuplot demos
require 'numeric trig'
gphelp=: 0 : 0
'd0' gpd0 term_png NB. create png file
'd0' gpd0 term_canvas NB. create html file
jhspng 'd0' gpd0 term_png NB. display in session
jhslink 'd1' gpd1 term_canvas NB. link to file
jhsshow 'd2' gpd2 term_canvas NB. show file in popup
'one' jhslink 'd0' gpd0 term_canvas NB. window named one
'one' jhslink 'd1' gpd1 term_canvas
'one' jhsshow 'd2' gpd2 term_canvas
'one' jhsshow 'd3' gpd3 term_canvas
'one' jhsshow 'd4' gpd4 term_canvas
'one' jhsshow 'd4' gpd4 term_canvas
)
term_png =: 'term png tiny size 400,200 background 0xffffff'
term_canvas =: gpcanvas 400 200;1;'plot'
term_canvas_mouseless=: gpcanvas 400 200;0;'plot'
gpd0=: 4 : 0
gpinit''
gpset y
gpset 'grid'
gpset 'title "sin(exp) vs cos(exp)"'
gpset 'xlabel "x-axis"'
gpset 'ylabel "y-axis"'
gpsetwith 'with lines title "sin(exp)", with lines title "cos(exp)"'
x gpplot (;sin@^,:cos@^) steps _1 2 100
)
gpd1=: 4 : 0
wiggle=. 4
points=. 200
X=. (3 % <:points) * i.points
fn=. +/@((0.9&^) * cos@((3&^ * (+/&X))))@i.
XY=. fn wiggle
gpinit''
gpset y
gpsetwith 'with lines'
x gpplot X;XY
)
gpd2=: 4 : 0
xd=. range _3 3 0.2
yd=. range _3 3 0.2
zd=. sin xd +/ sin yd
CP=. xd;yd;zd
gpinit''
gpset y
gpset 'title "sin(x+sin(y))"'
gpset 'parametric'
gpsetwith 'with lines'
gpsetsurface 1
x gpplot CP
)
gpd3=: 4 : 0
xd=. range _3 3 0.1
yd=. range _3 3 0.1
SP=. xd;yd;(sin xd) */ sin yd
gpinit''
gpset y
gpset 'title "sin(x)*sin(y)) contour plot"'
gpset 'parametric;contour;cntrparam levels 20;view 0,0,1;nosurface'
gpsetwith 'with lines'
gpsetsurface 1
x gpplot SP NB. surface plot
)
gpd4=: 4 : 0
gpinit''
gpset y
gpsetwith'with lines'
x gpplot 10?10
)