2 # $Id: pm3d.dem,v 1.18.2.1 2007/01/19 17:44:14 mikulik Exp $
4 # demo for pm3d splotting
6 # This demo can be directly used if your default terminal supports pm3d,
7 # like OS/2 Presentation Manager, X11, Linux VGA, Windows.
8 # Otherwise you can use the output to postscript, for example:
9 # set term push; set term postscript color enhanced
10 # set out 'pm3d_demo.ps'
12 # set out; set term pop
14 # Prepared by Petr Mikulik
16 # - 12. 3. 2003 pm: added demo for corners2color
17 # - 9. 3. 2002 pm: added demo for ftriangles
18 # - 31. 1. 2002 pm: removed pm3d/demo and stand-alone pm3d.dem in demo/
19 # - 29. 1. 2002 joze: added demo for the 4th column
20 # - 18. 3. 2001 pm: updated for cb-axis
21 # - 18.11. 2000 pm: updated for 'set colorbox'
22 # - 03. 3. 2000 joze: updated to show new pm3d features
23 # - 15. 6. 1999 pm: update for `set pm3d`+`set palette`
24 # - 29. 4. 1999 pm: the 1st version, directory pm3d/demo
27 # print "WARNING: This demo works only on terminals supporting pm3d, i.e. on "
28 # print "-------- OS/2 Presentation Manager, X11, Linux VGA, Windows. Please use"
29 # print " output to a postscript file otherwise."
41 set title "pm3d demo. Radial sinc function. Default options."
45 splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)
46 pause -1 "Hit return to continue"
48 set title "pm3d at s (surface) / ticslevel 0"
51 set cblabel "colour gradient"
53 pause -1 "Hit return to continue"
55 set title "pm3d at b (bottom)"
58 pause -1 "Hit return to continue"
60 set title "unset surface; set pm3d at st (surface and top)"
64 pause -1 "Hit return to continue"
68 set title "set pm3d at bstbst (funny combination, only for screen or postscript)"
72 pause -1 "Hit return to continue"
77 set samples 100; set isosamples 100
79 pause -1 "Hit return to continue"
81 set title "gray map, negative"
83 set palette gray negative
85 pause -1 "Hit return to continue"
87 set title "colour map, using default rgbformulae 7,5,15 ... traditional pm3d (black-blue-red-yellow)"
88 set palette color positive
90 set samples 50; set isosamples 50
92 pause -1 "Hit return to continue"
94 set title "colour, rgbformulae 3,11,6 ... green-red-violet"
95 set palette rgbformulae 3,11,6
97 pause -1 "Hit return to continue"
99 set title "colour, rgbformulae 23,28,3 ... ocean (green-blue-white); OK are also all other permutations"
100 set palette rgbformulae 23,28,3
102 pause -1 "Hit return to continue"
104 set title "colour, rgbformulae 30,31,32 ... color printable on gray (black-blue-violet-yellow-white)"
105 set palette rgbformulae 30,31,32
107 pause -1 "Hit return to continue"
109 set title "rgbformulae 31,-11,32: negative formula number=inverted color"
110 set palette rgbformulae 31,-11,32
112 pause -1 "Hit return to continue"
113 set yrange [*:*] noreverse
118 set title "set pm3d scansforward: wrong, because back overwrites front"
122 set samples 50; set isosamples 50
125 set pm3d at s scansforward
126 splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)
127 pause -1 "Hit return to continue"
129 set title "set pm3d scansbackward: correctly looking surface"
132 set pm3d scansbackward
134 pause -1 "Hit return to continue"
137 set title "set hidden3d"
138 set samples 30; set isosamples 30
146 pause -1 "Hit return to continue"
149 # draw the surface using pm3d's hidden3d with line type 100
153 set title "set pm3d hidden3d <linetype>: pm3d's much faster hidden3d variant"
154 set samples 30; set isosamples 30
156 set style line 100 lt 5 lw 0.5
157 set pm3d hidden3d 100
162 pause -1 "Hit return to continue"
165 set title "bad: surface and top are too close together"
173 pause -1 "Hit return to continue"
175 set title "solution: use independent 'set zrange' and 'set cbrange'"
180 pause -1 "Press Enter; I will continue by 'set autoscale cb' and much more..."
183 set title "color box is on by default at a certain position"
184 set samples 20; set isosamples 20
191 pause -1 "Hit return to continue"
193 set title "color box is on again, now with horizontal gradient"
194 set size 0.6,0.6; set origin 0.2,0.25
195 set colorbox horizontal
196 set colorbox user origin 0.1,0.15 size 0.8,0.1
199 set cblabel "see cblabel, grid cb, mcbtics, ..."
201 pause -1 "Hit return to continue"
203 unset cblabel; unset mcbtics; set grid nocb; set colorbox default
205 set title "color box is switched off"
208 pause -1 "Hit return to continue"
210 set title 'using now "set grid back; unset colorbox"'
216 pause -1 "Hit return to continue"
218 set size 1,1; set origin 0,0
219 set grid layerdefault
223 set sample 11; set isosamples 11
231 set title "Datafile with different nb of points in scans; pm3d flush begin"
232 set pm3d flush begin noftriangles scansforward
235 pause -1 "Hit return to continue"
237 set title "Datafile with different nb of points in scans; pm3d flush center"
238 set pm3d flush center scansforward
240 pause -1 "Hit return to continue"
242 set title "Datafile with different nb of points in scans; pm3d flush end"
243 set pm3d flush end scansforward
245 pause -1 "Hit return to continue"
250 set title "Data with different nb of points in scans; pm3d ftriangles flush begin"
251 set pm3d flush begin ftriangles scansforward
254 pause -1 "Hit return to continue"
256 set title "Data with different nb of points in scans; pm3d ftriangles flush center"
257 set pm3d flush center ftriangles scansforward
259 pause -1 "Hit return to continue"
261 set title "Data with different nb of points in scans; pm3d ftriangles flush end"
262 set pm3d flush end ftriangles scansforward
264 pause -1 "Hit return to continue"
266 set title "Using interpolation with datafile; pm3d map interpolate 2,1"
267 set pm3d flush begin noftriangles scansforward interpolate 2,1
269 pause -1 "Hit return to continue"
271 set title "Using interpolation with datafile; pm3d map ftriangles interpolate 10,1"
272 set pm3d flush begin ftriangles scansforward interpolate 10,1
274 pause -1 "Hit return to continue"
276 set title "Using interpolation with datafile; pm3d at s ftriangles interpolate 10,1"
277 set pm3d flush begin ftriangles scansforward at s interpolate 10,1
280 pause -1 "Hit return to continue"
284 set title "only for enhanced terminals: 'set format cb ...'"
287 set sample 31; set isosamples 31
288 set xrange [-185:185]
289 set yrange [-185:185]
290 set format cb "%.01t*10^{%T}"
294 set pm3d at s; set palette gray
295 set cblabel "the colour gradient"
296 splot abs(x)**3+abs(y)**3
297 pause -1 "Hit return to continue"
302 set xrange [*:*]; set yrange [*:*]
303 set title "function 'x+y' using all colors available, 'set pal maxcolors 0'"
306 pause -1 "Hit return to continue"
308 set xrange [*:*]; set yrange [*:*]
309 set title "function 'x+y' using only 5 colors, 'set pal maxcolors 5'"
312 pause -1 "Hit return to continue"
319 set title "color lines: 'splot sin(y)/(y) with lines palette'"
322 set xrange [-10:10]; set yrange [-10:10]
324 set isosamples 40,40; set samples 40,40
325 splot sin(y)/(y) w lines palette
326 pause -1 "Hit return to continue"
330 set title "Demo for clipping of 2 rectangles comes now. The xrange is [0:2]..."
331 set pm3d; set palette
336 pause -1 "Hit return to continue"
340 set title "...and now xrange is [0:1.5] and 'set pm3d clip1in'"
343 pause -1 "Hit return to continue"
345 set title "...now xrange is [0:1.5] and 'set pm3d clip4in'"
348 pause -1 "Hit return to continue"
353 sinc(u,v) = sin(sqrt(u**2+v**2)) /sqrt(u**2+v**2)
358 set title "pm3d explicit mode --- coloring according to the 4th parameter of 'using'"
361 set pm3d at s explicit
363 # 'binary2' binary u 1:2:(column(3)+column(-1)/20.0):3 w pm3d,
366 'binary2' binary u 1:2:3:($2+($1+$2)/10) w pm3d, \
368 pause -1 "Hit return to continue"
370 set title "coloring according to the 3rd 'using' parameter (left) and to the z-value (bottom)"
373 'binary2' binary u 2:(12 - column(3) * 10):1 notitle w lines, \
374 'binary2' binary u (-12 + column(3) * 10):2:1:(-12 + column(3) * 10) notitle w pm3d, \
375 'binary2' binary u 1:2:(column(3) * 10 - 12) notitle w pm3d
377 pause -1 "Hit return to continue"
381 print "Plot by pm3d algorithm draws quadrangles filled with color calculated from"
382 print "the z- or color-value of the surrounding 4 corners. The following demo shows"
383 print "different color spots for a plot with very small number of quadrangles (here"
384 print "rectangular pixels). Note that the default option is 'mean'."
397 set colorbox horizontal user origin 0.1,0.025 size .8,0.02
399 # Needed by terminals limited on colors:
400 #set palette maxcolors 26
402 # Note: no more space in the following multiplot to show demo for
403 #set pm3d corners2color median
404 #set pm3d corners2color geomean
407 # Let us do multiplot grid 3x3:
408 dx = 1.0/3; dy = 1.0/3;
412 set title "set pm3d corners2color c1"
413 set pm3d corners2color c1
417 set title "set pm3d corners2color c2"
418 set pm3d corners2color c2
422 set title "set pm3d corners2color c3"
423 set pm3d corners2color c3
427 set title "set pm3d corners2color c4"
428 set pm3d corners2color c4
432 set title "set pm3d corners2color mean"
433 set pm3d corners2color mean
437 set title "set pm3d corners2color geomean"
438 set pm3d corners2color geomean
442 set title "set pm3d corners2color median"
443 set pm3d corners2color median
447 set title "Original grid points"
453 #splot x*2+y with points ps 3 pt 5 palette
454 splot f(x,y) with linesp ps 3 pt 5 palette
457 pause -1 "Hit return to continue"
460 print "End of pm3d demo."