File: sampling.dem

package info (click to toggle)
gnuplot 6.0.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,940 kB
  • sloc: ansic: 95,319; cpp: 7,590; makefile: 2,470; javascript: 2,328; sh: 1,531; lisp: 664; perl: 304; pascal: 191; tcl: 88; python: 46
file content (150 lines) | stat: -rw-r--r-- 3,827 bytes parent folder | download | duplicates (6)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# 18 Aug 2017
# Each of these plot commands failed on some version between 5.0 and 5.3.
# I collect them here to use as unit tests for continued success
# of the code added to repair breakage.
#
# Usage:  call 'sampling.dem' <testno>
#

set urange [1:100]
set vrange [1:100]
set xrange [1:100]
set key opaque box
set style data line

if (ARGC < 1) ARG1 = 0

set trange [20:50]

if (ARG1 <= 1) {
    print "test 1: explicit trange distinct from xrange"
    plot '+' using 1:(10. + sin($1)) title "trange [20:50]"
    pause -1 "Hit <cr> to continue"
}

if (ARG1 <= 2) {
    print "test 2: range set by 'sample' keyword, linear x axis"
    plot sample [t=20:50] '+' using (t):(10. + sin(t))
    pause -1 "Hit <cr> to continue"
}


set log x

if (ARG1 <= 3) {
    print "test 3: range set by 'sample' keyword, logscale x axis"
    plot sample [t=20:50] '+' using (t):(10. + sin(t))
    pause -1 "Hit <cr> to continue"
}

unset log

if (ARG1 <= 4) {
    print "test 4: splot '++' with autoscaled y (linear xy)"
    splot '++' using 1:2:($1*$2)
    pause -1 "Hit <cr> to continue"
}

set log xy

if (ARG1 <= 5) {
    print "test 5: splot '++' with autoscaled y (logscale xy)"
    splot '++' using 1:2:($1*$2)
    pause -1 "Hit <cr> to continue"
}

unset log

if (ARG1 <= 6) {
    print "test 6: plot '++' with image (linear xy)"
    plot '++' using 1:2:($1*$2) with image
    pause -1 "Hit <cr> to continue"
}


set log xy

if (ARG1 <= 7) {
    print "test 7: plot '++' with image (logscale xy)"
    plot '++' using 1:2:($1*$2) with image
    pause -1 "Hit <cr> to continue"
}

reset 
#
#  piecewise functions along nonlinear x axis
#
unset border
set key center top reverse Left
set xzeroaxis
set yzeroaxis
set xtics axis out scale 1,8
set xtics add  (1.00000 1, 6.28319 1)
set ytics axis
set xrange [ .1 : 12 ] noreverse nowriteback



if (ARG1 <= 8) {
    print "test 8: multiple sampling ranges in one 2D plot command"
    set multiplot layout 2,1
    set title "Piecewise function sampling along linear x" font ",13"
    plot sample [*:1] x, [1:2.*pi] cos(x), [2.*pi:10] (x-8)**2
    set nonlinear x via x inv x
    set title "nonlinear (identity mapped) x" font ",13"
    plot sample [*:1] x, [1:2.*pi] cos(x), [2.*pi:10] (x-8)**2
    unset multiplot
    pause -1 "Hit <cr> to continue"
}

reset

set xrange [1:100]
set yrange [1:100]
set urange [0:100]
set vrange [70:90]
set style data lines
set xyplane at 0

set hidden3d
set title "3D sampling range distinct from plot x/y range"
print "test 9: 3D sampling range distinct from plot x/y range"

splot '++' using 1:2:($1*25.*sin($2/10)), \
      [u=30:70][v=0:50] '++' using 1:2:(u*v), \
      [u=40:80][v=30:60] '++' using (u):(v):(u*sqrt(v)) lt 4, \
      [u=1:100][v=500:1000] '++' using (90):(u):(v) lt 6

pause -1 "Hit <cr> to continue"

reset

unset key
set view map
set xrange [ 20:100 ]
set yrange [ 0:80 ]
set size ratio 1.0
radius(x,y) = 10 * sqrt((x-50)**2 + (y-50)**2)
alpha(x,y) = radius(x,y) > 255 ? 0 : 255-radius(x,y)
set title "3D custom sampling on u and v using pseudofile '++'"
print "test 10: splot '++' with explicit sampling intervals"

splot sample [u=25:75:1][v=25:75:4] '++' \
      using 1:2:0:(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha, \
      [u=25:75:4][v=25:75:1] '++' \
      using (u+20):(v-20):0:(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha

pause -1 "Hit <cr> to continue"

set title "2D custom sampling on u and v using pseudofile '++'"
print "test 10: plot '++' with explicit sampling intervals"

plot sample [u=25:75:1][v=25:75:4] '++' \
      using 1:2:(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha, \
      [u=25:75:4][v=25:75:1] '++' \
      using (u+20):(v-20):(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha

pause -1 "Hit <cr> to continue"

reset