1# 18 Aug 2017
2# Each of these plot commands failed on some version between 5.0 and 5.3.
3# I collect them here to use as unit tests for continued success
4# of the code added to repair breakage.
5#
6# Usage:  call 'sampling.dem' <testno>
7#
8
9set urange [1:100]
10set vrange [1:100]
11set xrange [1:100]
12set key opaque box
13set style data line
14
15if (ARGC < 1) ARG1 = 0
16
17set trange [20:50]
18
19if (ARG1 <= 1) {
20    print "test 1: explicit trange distinct from xrange"
21    plot '+' using 1:(10. + sin($1)) title "trange [20:50]"
22    pause -1 "Hit <cr> to continue"
23}
24
25if (ARG1 <= 2) {
26    print "test 2: range set by 'sample' keyword, linear x axis"
27    plot sample [t=20:50] '+' using (t):(10. + sin(t))
28    pause -1 "Hit <cr> to continue"
29}
30
31
32set log x
33
34if (ARG1 <= 3) {
35    print "test 3: range set by 'sample' keyword, logscale x axis"
36    plot sample [t=20:50] '+' using (t):(10. + sin(t))
37    pause -1 "Hit <cr> to continue"
38}
39
40unset log
41
42if (ARG1 <= 4) {
43    print "test 4: splot '++' with autoscaled y (linear xy)"
44    splot '++' using 1:2:($1*$2)
45    pause -1 "Hit <cr> to continue"
46}
47
48set log xy
49
50if (ARG1 <= 5) {
51    print "test 5: splot '++' with autoscaled y (logscale xy)"
52    splot '++' using 1:2:($1*$2)
53    pause -1 "Hit <cr> to continue"
54}
55
56unset log
57
58if (ARG1 <= 6) {
59    print "test 6: plot '++' with image (linear xy)"
60    plot '++' using 1:2:($1*$2) with image
61    pause -1 "Hit <cr> to continue"
62}
63
64
65set log xy
66
67if (ARG1 <= 7) {
68    print "test 7: plot '++' with image (logscale xy)"
69    plot '++' using 1:2:($1*$2) with image
70    pause -1 "Hit <cr> to continue"
71}
72
73reset
74#
75#  piecewise functions along nonlinear x axis
76#
77unset border
78set key center top reverse Left
79set xzeroaxis
80set yzeroaxis
81set xtics axis out scale 1,8
82set xtics add  (1.00000 1, 6.28319 1)
83set ytics axis
84set xrange [ .1 : 12 ] noreverse nowriteback
85
86
87
88if (ARG1 <= 8) {
89    print "test 8: multiple sampling ranges in one 2D plot command"
90    set multiplot layout 2,1
91    set title "Piecewise function sampling along linear x" font ",13"
92    plot sample [*:1] x, [1:2.*pi] cos(x), [2.*pi:10] (x-8)**2
93    set nonlinear x via x inv x
94    set title "nonlinear (identity mapped) x" font ",13"
95    plot sample [*:1] x, [1:2.*pi] cos(x), [2.*pi:10] (x-8)**2
96    unset multiplot
97    pause -1 "Hit <cr> to continue"
98}
99
100reset
101
102set xrange [1:100]
103set yrange [1:100]
104set urange [0:100]
105set vrange [70:90]
106set style data lines
107set xyplane at 0
108
109set hidden3d
110set title "3D sampling range distinct from plot x/y range"
111print "test 9: 3D sampling range distinct from plot x/y range"
112
113splot '++' using 1:2:($1*25.*sin($2/10)), \
114      [u=30:70][v=0:50] '++' using 1:2:(u*v), \
115      [u=40:80][v=30:60] '++' using (u):(v):(u*sqrt(v)) lt 4, \
116      [u=1:100][v=500:1000] '++' using (90):(u):(v) lt 6
117
118pause -1 "Hit <cr> to continue"
119
120reset
121
122unset key
123set view map
124set xrange [ 20:100 ]
125set yrange [ 0:80 ]
126set size ratio 1.0
127radius(x,y) = 10 * sqrt((x-50)**2 + (y-50)**2)
128alpha(x,y) = radius(x,y) > 255 ? 0 : 255-radius(x,y)
129set title "3D custom sampling on u and v using pseudofile '++'"
130print "test 10: splot '++' with explicit sampling intervals"
131
132splot sample [u=25:75:1][v=25:75:4] '++' \
133      using 1:2:0:(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha, \
134      [u=25:75:4][v=25:75:1] '++' \
135      using (u+20):(v-20):0:(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha
136
137pause -1 "Hit <cr> to continue"
138
139set title "2D custom sampling on u and v using pseudofile '++'"
140print "test 10: plot '++' with explicit sampling intervals"
141
142plot sample [u=25:75:1][v=25:75:4] '++' \
143      using 1:2:(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha, \
144      [u=25:75:4][v=25:75:1] '++' \
145      using (u+20):(v-20):(u*4-50):(v*4-50):(255*sin(u*v/2500.)):(alpha(u,v)) with rgbalpha
146
147pause -1 "Hit <cr> to continue"
148
149reset
150
151