1 # demo for plotting images using pixels and binary 2d data
3 # This demo can be used for terminals supporting image display.
4 # Currently supported are: X11, Aqua, postscript, png, pdf, svg,
7 # Prepared by Dan Sebald
9 # - 9.23. 2003 ds: redone in response to discussion list feedback
10 # - 5. 3. 2003 ds: 1st version
12 if ((GPVAL_VERSION == 4.1 || GPVAL_VERSION == 4.2) \
13 && (!strstrt(GPVAL_COMPILE_OPTIONS,"+IMAGE"))) \
14 print ">>> Skipping demo <<<\n" ; \
15 print "This copy of gnuplot was built without support for plotting images" ; \
19 print "The plotting styles \`image\` and \`rgbimage\` are intended for plotting"
20 print "images described in a data file either in the convential ASCII format or"
21 print "in a binary format described by the qualifiers \`binary\` and \`using\`."
22 print "All pixels have an (x,y) or (x,y,z) coordinate. These values can be"
23 print "included in the data file or implicitly determined with the sampling"
24 print "\'array\' key word and sampling periods \'dx\' and \'dy\'. The key words"
25 print "\'rotate\' and, for 3d plots, \'perpendicular\' control orientation."
26 print "\nThe data for this image was stored as RGB triples, one byte per channel,"
27 print "without (x,y) coordinate information. This yields a most compact file."
28 print "The plotting command is displayed on the graph."
31 set title "Larry Ewing's GIMP penguin on vacation basking in\nthe balmy waters off the coast of Murmansk"
34 set label "\"I flew here... by plane. Why? For the halibut.\"" at 64,135 center
35 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar' with rgbimage
36 pause -1 "Hit return to continue"
40 print "Images are typically stored in a file with the first datum being the"
41 print "top, left pixel. Without the ability to translate coordinates, the"
42 print "the result would be an upside down image."
44 print "The key word \'array\' means an implied sample array is applied"
45 print "to generate the locations of file data using the sampling periods"
46 print "dx, dy and dz. The x-dimension is always the contiguous points in"
47 print "a binary file. The y-dimension is the line number which is incremented"
48 print "upon the x-dimension reaching the line length. The z-dimension is"
49 print "the plane number which is incremented upon the y-dimension reaching"
50 print "the number of lines per plane."
52 print "To alter the location of the binary data when displayed via the \'plot\'"
53 print "command, use the key word \'rotate\' along with changing the sign of dx, dy"
56 set title "Translations of position variables via 'using'"
60 set label "\"Time for a dip...\"" at 132,285 center
61 plot 'blutux.rgb' binary array=128x128 flipy center=( 64,201 ) format='%uchar' with rgbimage, \
62 'blutux.rgb' binary array=128x128 flipy rotation=-90d center=(201,201) format='%uchar' with rgbimage, \
63 'blutux.rgb' binary array=128x128 flip=y rotate=3.1415 center=(201,64) format='%uchar' with rgbimage, \
64 'blutux.rgb' binary array=128x128 flip=y rot=0.5pi center=(64,64) format='%uchar' using 1:2:3 with rgbimage
65 pause -1 "Hit return to continue"
69 print "There is the ability to plot both color images and palette based"
70 print "images. This is controlled by the styles \`image\`, which derives"
71 print "color information from the current palette, and \`rgbimage\`,"
72 print "which requires three components representing the red, blue and"
73 print "green primary color scheme."
75 print "By the way, if you have a mouse active, click the right button"
76 print "inside the image to isolate a portion of the image and see what"
82 set label 1 "\"I am the penguin, GOO GOO GOO JOOB.\"" at 63,140 center
83 set title "Palette mode 'image' used to produce psychedelic bird"
85 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar%uchar%uchar' using ($1+$2+$3) with image
86 pause -1 "Hit return to continue"
90 print "Naturally, as with 3d color surfaces, the palette may be changed."
91 print "This is an example of gray scale."
93 print "Also, notice in the plot command the key word \'flipy\'. This"
94 print "means to change the direction of the sample along the y dimension"
95 print "and is useful for the situation where images or other data are"
96 print "stored in some direction other than that of the Cartesion system."
97 print "Alone, \'flipD\' means do flipping in the D (x y or z) direction"
98 print "for all records. Individual records can be controlled using the"
99 print "syntax \'flipD=#,...,#\', where # is \'0\' or \'1\'."
105 set label 1 "\"This picture was taken by my friend Ansel Adams.\"" at 63,140 center
106 set title "The palette can be changed from color to gray scale"
109 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar%uchar%uchar' using ($1+$2+$3)/3 with image
110 pause -1 "Hit return to continue"
114 print "Also, similar to 3d color surface plots, a color box showing the"
115 print "palette mapping scheme can be added to the plot. The default"
116 print "location is the right edge of the plot. The location can be set"
117 print "manually using \`set colorbox\` and \`set margin\`."
119 print "As a prelude to the next graph, resize the plot window to judge"
120 print "the refresh speed of the image drawing routine. Notice that when"
121 print "the window is smaller, the image refresh is faster. There is more"
122 print "decimation in the data of the original image and less data to plot."
123 print "Furthermore, the window continues to refresh at a reasonable rate"
124 print "even when the input image size becomes large (e.g., 1024 x 1024)"
125 print "because the number of pixels on the screen remains about the same"
126 print "while much of the hi resolution data is decimated."
135 set title "As with 3d color surfaces, a color box may be added to the plot"
136 splot 'blutux.rgb' binary array=128x128 flipy format='%uchar%uchar%uchar' using ($1+$2+$3)/3 with image
137 pause -1 "Hit return to continue"
140 print "The \'rotation\' key word works not only with angles of integer"
141 print "multiples of 90 degrees but also arbitrary rotations. When"
142 print "constructing an image, Gnuplot verifies that pixel locations"
143 print "form a valid grid. Pixel widths are based upon the grid"
144 print "spacing. If the image orientation is aligned with the view"
145 print "axes, Gnuplot uses an efficient image driver routine. Otherwise,"
146 print "individual pixels are drawn using polygon shapes."
148 print "Resize this window and compare the plot's refresh rate to that of"
149 print "the previous and next plot. Notice how in this example if the"
150 print "window is small the image refresh does not speed up. Unlike the"
151 print "image routine where image data is decimated, all color rectangles"
152 print "must be redrawn no matter the size of the output image."
154 print "Also notice how the center of the image matches the tuple specified"
155 print "with the key word \'center\' in the plot command. Before doing the"
156 print "rotation, the image's natural center is subtracted, and after doing"
157 print "the rotation, the specified center is added."
163 set title "Polygons used to draw pixels for rotated images\nNotice the slower refresh rate than for the next plot"
165 plot 'blutux.rgb' binary array=128x128 dx=0.70711 dy=0.70711 flipy rotation=45d center=(63.5,63.5) format='%uchar' using ($1+$2+$3)/3 with image
166 pause -1 "Hit return to continue"
170 print "The image of this plot is rotated 90 degrees and can utilize the"
171 print "efficient image functions of terminal drivers. The plot refresh"
172 print "is faster than the previous plot."
174 print "Furthermore, the image location in this case is specified via the"
175 print "\'origin\' key word. As such, the rotation is done about the origin"
176 print "as opposed to the center of the image. Notice the difference in"
183 set title "Terminal image routine used to draw plot rotated about origin\nNotice the faster refresh rate than for the previous plot"
185 plot 'blutux.rgb' binary array=128x128 dx=1 flip=y rotation=0.5pi origin=(0,0) format='%uchar' using ($1+$2+$3)/3 with image
186 pause -1 "Hit return to continue"
190 print "Algebraic manipulation of the input variables can select various"
191 print "components of the image. Here are three examples where two"
192 print "channels--or analogous to the ASCII file, data \"columns\"--are ignored"
193 print "This is done by using \`*\` in the format to indicate that a variable"
194 print "of a certain size should be discarded. For example, to select the"
195 print "green channel, \`%*uchar%uchar%*uchar\` is one alternative."
203 set xrange [-0.5:127.5]
204 set yrange [-0.5:127.5]
206 set label 1 "Selection of the input channels via \`using\`" at 140,160 center
207 set title '"I do impersonations..."' offset 0,-0.5
208 plot 'blutux.rgb' binary array=128x128 flip=y format='%uchar' using 1:2:3 with rgbimage
212 set title '"A cardinal."'
213 plot 'blutux.rgb' binary array=128x128 flip=y format='%uchar%*uchar%*uchar' using 1:(0):(0) with rgbimage
216 set title '"A parrot."'
217 plot 'blutux.rgb' binary array=128x128 flipy format='%*uchar%uchar%*uchar' using (0):1:(0) with rgbimage
220 set title '"A bluebird."'
221 plot 'blutux.rgb' binary array=128x128 flipy format='%*uchar%*uchar%uchar' using (0):(0):1 with rgbimage
223 pause -1 "Hit return to continue"
227 print "The range of valid pixel values can be set via \`cbrange\`. If the"
228 print "\`cbrange\` is in autoscale mode, Gnuplot will attempt to adjust the"
229 print "luminance based upon the maximum pixel value in the image. Previous"
230 print "graphs all had the \`cbrange\' in autoscale mode. However, there are"
231 print "instances where one may want to force the image luminance or palette"
232 print "to be of a certain range. For example, each channel of the penguin"
233 print "image has an 8-bit depth, and hence the valid range is from 0 to 255."
234 print "The logical choice of \`cbrange\' is [0:255]. This is done in the"
235 print "upper left image. However, the image can be saturated by choosing a"
236 print "smaller range, as done in the upper right image. Expanding the color"
237 print "box range will darken the image, as shown in the bottom examples."
245 set xrange [-0.5:127.5]
246 set yrange [-0.5:127.5]
248 set label 1 "Luminance adjustment via \`cbrange\`" at 140,160 center
249 set title 'Lake Mendota, "or Wonk-sheck-ho-mik-la!"' offset 0,-0.5
251 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar' using 1:2:3 with rgbimage
255 set title '"Lucky I brought sunscreen."'
257 plot 'blutux.rgb' binary array=128x128 flip=y format='%uchar' using 1:2:3 with rgbimage
260 set title 'Sunset on the Terrace'
262 plot 'blutux.rgb' binary array=128x128 flip=y format='%uchar' using (1.5*$1):2:3 with rgbimage
265 set title 'Sultry evening'
267 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar' using 1:2:3 with rgbimage, '-' w points pt 7 ps 6 lt -2, '-' w points pt 7 ps 0.65 lt -2
279 pause -1 "Hit return to continue"
282 # Repeat of the 'using.dem' demo, but with binary 2d data. 'using.bin' is
283 # in the format int32, int8, int16/100, int8, int16/100, int16/100.
286 print "Not only can the 2d binary data mode be used for image data."
287 print "Here is an example that repeats the \`using.dem\` demo with the"
288 print "same data, but stored in binary format of differing sizes. It"
289 print "uses different format specifiers within the \'format\' string."
290 print "There are machine dependent and machine independent specifiers,"
291 print "display by the command \'show datafile binary datasizes\':"
293 show datafile binary datasizes
295 set title "Convex November 1-7 1989 Circadian"
298 plot 'using.bin' binary format='%*int32%int8%*int16%int8%*int16%*int16' using 1:2 title "Logged in" with impulses,\
299 'using.bin' binary format='%*int32%int8%*int16%int8%*int16%*int16' using 1:2 title "Logged in" with points
300 pause -1 "Hit return to continue"
304 print "Again, a different format specification for \`using\` can be"
305 print "used to select different \"columns\" within the file."
308 set title "Convex November 1-7 1989"
310 set label "(Weekend)" at 5,25 center
311 plot 'using.bin' binary format='%*int32%*int8%int16%int8%*int16%*int16' using ($1/100):2 title "Logged in" with impulses,\
312 'using.bin' binary format='%*int32%*int8%int16%*int8%int16%*int16' using ($1/100):($2/100) t "Load average" with points,\
313 'using.bin' binary format='%*int32%*int8%int16%*int8%*int16%int16' using ($1/100):($2/100) t "%CPU used" with lines
315 pause -1 "Hit return to continue"
319 print "Here is another example, one repeating the \`scatter.dem\`"
320 print "demo. With binary data we cannot have blank lines to"
321 print "indicate a break in data, as is done with ASCII files."
322 print "Instead, we can specify the record lenths in the command."
323 print "In this case, the data file contains the (x,y,z) coordinate"
324 print "information, hence implicit derivation of that information"
325 print "is not desired. Instead, the record lengths can be specified"
326 print "using the keyword \'record\', which behaves the same as"
327 print "\'array\' but does not generate coordinates. The command is"
328 print "displayed on the graph."
330 set title "2d binary data example where record length is part of command"
331 splot 'scatter2.bin' binary endian=little record=30:30:29:26 using 1:2:3
332 pause -1 "Hit return to continue"
336 print "For binary data, the byte endian format of the file and of the"
337 print "compiler often require attention. Therefore, the key word"
338 print "\'endian\' is provided for setting or interchanging byte"
339 print "order. The allowable types are \'little\', \'big\', and"
340 print "depending upon how your version of Gnuplot was compiled,"
341 print "\'middle\' (or \'pdp\') for those still living in the medieval"
342 print "age of computers. These types refer to the file's endian."
343 print "Gnuplot arranges bytes according to this endian and what it"
344 print "determines to be the compiler's endian."
346 print "There are also the special types \'default\' and \'swap\' (or"
347 print "\'swab\') for those who don't know the file type but realize"
348 print "their data looks incorrect and want to change the byte read"
351 print "Here is an example showing the \`scatter.dem\` data plotted"
352 print "with correct and incorrect byte order. The file is known"
353 print "to be little endian, so the upper left plot is correct"
354 print "appearance and the upper right plot is incorrect appearance."
355 print "The lower two plots are default and swapped bytes. If the"
356 print "plots within the columns match, your compiler uses little"
357 print "endian. If diagonal plots match then your compiler uses"
358 print "big endian. If neither of the bottom plots matches the"
359 print "upper plots, Tux says you're living in the past."
367 set label 1 "If plots in columns match, your compiler is little endian" at 100,1200,3.0 center
368 set title 'Little endian' offset 0,-0.5
369 splot 'scatter2.bin' binary record=30:30:29:26 endian=little using 1:2:3
373 set title 'Big endian'
374 splot 'scatter2.bin' binary record=30:30:29:26 endian=big using 1:2:3
378 splot 'scatter2.bin' binary record=30:30:29:26 endian=default using 1:2:3
382 splot 'scatter2.bin' binary record=30:30:29:26 endian=swap using 1:2:3
384 pause -1 "Hit return to continue"
388 print "This close up of a 2x2 image illustrates how pixels surround the"
389 print "sampling grid points. This behavior is slightly different than"
390 print "that for pm3d where the four grid points would be used to create"
391 print "a single polygon element using an average, or similar mathematical"
392 print "combination, of the four values at those points."
394 set title "Close up of pixels having grid points (0,0), (0,2), (2,0) and (2,2)"
395 set xrange [-1.5:3.5]
396 set yrange [-1.5:3.5]
399 plot '-' with rgbimage, '-' with points pt 7 ps 2 lt -1
410 pause -1 "Hit return to continue"
414 print "Lower dimensional data may be extended to higher dimensional plots"
415 print "via a number of simple, logical rules. The first step Gnuplot does"
416 print "is sets the components for higher than the natural dimension of the"
417 print "input data to zero. For example, a two dimensional image can be"
418 print "displayed in the three dimensional plot as shown. Without"
419 print "translation, the image lies in the x/y-plane."
421 set title "Simple extension of a two dimensional image into three dimensions"
425 splot 'blutux.rgb' binary array=128x128 flip=y format='%uchar%uchar%uchar' using ($1+$2+$3)/3 with image
426 pause -1 "Hit return to continue"
430 print "The key words \'rotate\' and \'center\' still apply in \'splot\' with"
431 print "rules similar to their use in \'plot\'. However, the center must be"
432 print "specified as a three element tuple."
435 set title "Orientation operations from \'plot\' also apply to to \'splot\'"
436 splot 'blutux.rgb' binary array=128x128 flipy rotate=90d center = (63.5,63.5,50) format='%uchar%uchar%uchar' using ($1+$2+$3) with image
437 pause -1 "Hit return to continue"
441 print "To have full degrees of freedom in orienting the image, an additional"
442 print "key word, \'perpendicular\', can translate the x/y-plane of the 2d"
443 print "data so that it lies orthogonal to a vector given as a three element"
444 print "tuple. The default vector is, of course, (0,0,1). The vector need"
445 print "not be of unit length, as this example illustrates. Viewing this"
446 print "plot with the mouse active can help visualize the image's orientation"
447 print "by panning the axes."
449 set title "The key word \'perpendicular\' applies only to \'splot\'"
451 set style line 1 lt -1 lw 1
452 set style line 2 lt -1 lw 1
453 set style arrow 1 nohead ls 1
454 set style arrow 2 head filled size screen 0.025,30,45 ls 2
455 set arrow from -10,0,0 to 10,0,0 as 1
456 set arrow from 0,-10,0 to 0,10,0 as 1
457 set arrow from 0,0,-10 to 0,0,10 as 1
458 set arrow from 0,0,0 to 30,30,30 as 2
459 splot 'blutux.rgb' binary array=128x128 flipy rot=1.0pi center = (63.5,63.5,50) perp=(1,1,1) format='%uchar%uchar%uchar' using ($1+$2+$3)/3 with image
460 pause -1 "Hit return to continue"
464 print "These concepts of extending lower dimensional data also apply"
465 print "to temporal-like signals. For example, a uniformly sampled"
466 print "sinusoid, sin(1.75*pi*x), in a binary file having no data for"
467 print "the independent variable can be displayed along any direction"
468 print "for both \'plot\'..."
478 set label 1 "Temporal data having one generated coordinate" at 2.25,1.5 center
479 set title 'Along the x-axis' offset 0,-0.5
480 plot 'sine.bin' binary endian=little array=201 dx=0.01 origin=(0,0) format='%f' using 1 with lines
486 set title 'Along the y-axis'
487 plot 'sine.bin' binary endian=little array=201 dx=0.01 origin=(0,0) rotate=0.5pi format='%f' with lines
490 set xrange [-2.2:0.7]
491 set yrange [-2.2:0.7]
492 set title 'Along a 225 degree projection'
493 plot 'sine.bin' binary endian=little array=201 dx=0.01 rotate=225d origin=(0,0) format='%f' using 1 with lines
495 pause -1 "Hit return to continue"
499 print "...and \'splot\'. Here is the \'scatter.dem\' example again,"
500 print "but this simulates the case of the redundant x coordinates not"
501 print "being in the binary file. The first \"column\" of the binary"
502 print "file is ignored and reconstructed by orienting the various"
503 print "data records."
505 set title "2d binary data example where x coordinate is ignored then generated"
509 splot 'scatter2.bin' binary endian=little record=30:30:29:26 origin=(25,0,0):(50,0,0):(75,0,0):(100,0,0) format='%f%f' using (0):2:3
510 pause -1 "Hit return to continue"
514 print "Some binary data files have headers, which may be skipped via"
515 print "the \'skip\' key word. Here is the \'scatter.dem\' example"
516 print "again, but this time the first and third traces are skipped."
517 print "The first trace is 30 samples of three floats so takes up 360"
518 print "bytes of space. Similarly, the third trace takes up 348 bytes."
520 set title "The key word \'skip\' used to ignore some data"
524 splot 'scatter2.bin' binary endian=little record=30:26 skip=360:348 origin=(50,0,0):(100,0,0) format='%f%f' using (0):2:3
525 pause -1 "Hit return to continue"
529 print "Generating uniformly spaced coordinates is valid for polar"
530 print "plots as well. This is useful for data acquired by machines"
531 print "sampling in a circular fashion. Here the sinusoidal data"
532 print "of the previous 2D plot put on a polar plot. Note the"
533 print "pseudonyms \'dt\' meaning sample period along the angular,"
534 print "or theta, direction. In Gnuplot, cylindrical coordinate"
535 print "notation is (t,r,z). [Different from common math convention"
539 set title "Uniform sampling in the polar coordinate system"
542 set xrange [-1.3:1.3]
543 set yrange [-1.3:1.3]
544 # The sinusoid has period T=8/7. Also, dx=0.01. So solving 8/7 dt = 2/3 pi dx, we get dt = 0.018326.
545 plot 'sine.bin' binary endian=little array=201 dt=0.018326 origin=(0,0) format='%f' using 1 with lines
546 pause -1 "Hit return to continue"
550 print "Binary data stored in matrix format (i.e., gnuplot binary)"
551 print "may also be translated with similar syntax. However, the"
552 print "binary keywords \`format\`, \`array\` and \`record\` do not apply"
553 print "because gnuplot binary has the requirements of float data"
554 print "and grid information as part of the file. Here is an"
555 print "example of a single matrix binary file input four times,"
556 print "each translated to a different location with different"
563 set title "Matrix binary data (gnuplot binary) translated"
567 set zrange [-0.2:1.2]
568 splot "binary3" binary center=(1.5,1.5,0), \
569 "binary3" binary center=(10.5,1.5,0) rotate=0.5pi u 1:2:3, \
570 "binary3" binary center=(10.5,10.5,0) rotate=1.0pi u 1:2:3, \
571 "binary3" binary center=(1.5,10.5,0) rotate=1.5pi u 1:2:3
572 pause -1 "Hit return to continue"
576 print "As with ASCII data, decimation in various directions can"
577 print "be achieved via the \`every\` keyword. (Note that no down-"
578 print "sampling filter is applied such that you risk aliasing data"
579 print "with the \`every\` keyword."
581 print "Here is a series of plots with increasing decimation."
587 set title "Non-decimated matrix data file"
591 splot "binary2" binary
592 pause -1 "Hit return to continue"
593 set title "Decimate by two in first dimension"
594 splot "binary2" binary every 2
595 pause -1 "Hit return to continue"
596 set title "Decimate by three in second dimension"
597 splot "binary2" binary every :3
598 pause -1 "Hit return to continue"
599 set title "Decimate by four in both dimensions"
600 splot "binary2" binary every 4:4
601 pause -1 "Hit return to continue"
605 print "Decimation works on general binary data files as well. Here is the"
606 print "image file with increasing decimation."
608 set title "Decimation works on general binary data files as well.\nLet Tux have his fun..."
611 set label 1 "\"Can I do that?\"" at 64,116 center
612 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar' every 1:1:43:15:83:65 with rgbimage
613 pause -1 "Hit return to continue"
614 set title "... Sure, go ahead."
617 set label 1 "\"Picasso's \'Penguin on Beach\'\"" at 64,139 center
618 plot 'blutux.rgb' binary array=128x128 flipy format='%uchar' every 8:8 with rgbimage
619 pause -1 "Hit return to continue"
623 print "Gnuplot understands a few common binary formats. Internally"
624 print "a function is linked with various extensions. When the"
625 print "extension is specified at the command line or recognized via"
626 print "a special file type called \'auto\', Gnuplot will call the"
627 print "function that sets up the necessary binary information. The"
628 print "known extensions are displayed using the \'show filetype\'"
629 print "command. E.g.,"
631 show datafile binary filetypes
632 print "Here's an example where an EDF file is recognized when Gnuplot"
633 print "is in \'auto\' mode. Details are pulled from the header of"
634 print "file itself and not specified at the command line. The command"
635 print "line can still be used to over-ride in-file attributes."
637 set title "Automatically recognizing file type and extracting file information"
638 plot 'demo.edf' binary filetype=auto with image
639 pause -1 "Hit return to continue"
643 print "The \'flip\', \'rotate\' and \'perpendicular\' qualifiers"
644 print "should provide adequate freedom to orient data as desired."
645 print "However, there is an additional key words \'scan\' which may"
646 print "offer a more direct and intuitive manner of orienting data"
647 print "depending upon the user's application and perspective."
649 print "\'scan\' is a 2 or 3 letter string representing how Gnuplot"
650 print "should derive (x,y), (x,y,z), (t,r) or (t,r,z) from the"
651 print "the datafile's scan order. The first letter pertains to the"
652 print "fastest rate or point-by-point increment. The second letter"
653 print "pertains to the medium rate or line-by-line increment. If"
654 print "there is a third letter, it pertains to the slowest rate or"
655 print "plane-by-plane increment. The default or inherent scan order"
656 print "is \'scan=xyz\'."
658 print "The pseudonym \'transpose\' is equivalent to \'scan=yx\' when"
659 print "generating 2D coordinates and \'scan=yxz\' when generating"
660 print "3D coordinates."
662 print "There is a subtle difference between the behavior of \'scan\'"
663 print "when dimension info is taken from the file itself as opposed"
664 print "to entered at the command line. When information is gathered"
665 print "from the file, internal scanning is unaltered so that issuing"
666 print "the \'scan\' command may cause the number of samples along"
667 print "the various dimensions to change. However, when the qualifier"
668 print "\'array\' is entered at the command line, the array dimensions"
669 print "adjust so that \'array=XxYxZ\' is always the number of samples"
670 print "along the Cartesian x, y and z directions, respectively."
681 set title 'Details read from file' offset 0,-0.5
682 plot 'demo.edf' binary filetype=auto with image
685 set title 'Transpose of file-read axes parameters'
686 plot 'demo.edf' binary filetype=auto transpose with image
689 set title 'Details specified at command line'
690 set label 1 "array=32x64 dx=10 dy=5 scan=xy" at 315,500 center
691 plot 'demo.edf' binary array=32x64 dx=10 dy=5 scan=xy skip=1024 format="%*float%float" using 1 with image
694 set title 'Transpose of command line axes parameters'
695 set label 1 "array=64x32 dx=5 dy=10 scan=yx" at 315,500 center
696 plot 'demo.edf' binary array=64x32 dx=5 dy=10 scan=yx skip=1024 format="%*float%float" using 1 with image
699 pause -1 "Hit return to continue"
703 print "It is possible to enter binary data at the command line. Of"
704 print "course, the limitation to this approach is that keyboards will"
705 print "allow entering only a limited subset of the possible character"
706 print "values necessary to represent general binary data. For this"
707 print "reason, the primary application for binary data at the command"
708 print "line is using Gnuplot through a pipe. For example, if a pipe"
709 print "is established with a C program, the function \'fputs()\' can"
710 print "send ASCII strings containing the Gnuplot commands while the"
711 print "function \'fwrite()\' can send binary data."
713 print "Furthermore, there can be no special ending character such as"
714 print "in the case of ASCII data entry where \'e\' represents the end"
715 print "of data for the special file \'-\'. It is important to note"
716 print "that when \'binary\' is specified, Gnuplot will continue"
717 print "reading until reaching the number of elements specified via"
718 print "the \'array\' or \'record\' command."
720 print "Here is an example of binary data at the command line where"
721 print "keyboard input has been side stepped by copying 48 bytes from"
722 print "a pre-existing binary file into this demo file."
724 set title "Binary data specified at the command line, intended for use through pipe"
725 set xrange [-1.5:3.5]
726 set yrange [-1.5:3.5]
728 plot '-' binary endian=little array=2x2 dx=2 format="%float" using 1:2:3 with rgbimage,\
729 '-' binary endian=little record=4 format="%char" using 1:2 with points pt 7 ps 2 lt -1
730 \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\0\0\0\0\0\0\0\0?
\0\0\0\ 2\ 2\0\ 2\ 2
731 pause -1 "Hit return to continue"
735 print "ASCII data files have a matrix variant. Unlike matrix binary,"
736 print "ASCII binary may have multiple matrices per file, separted"
737 print "by a blank line. The keyword \`index\` can select the desired"
738 print "matrix to plot."
750 set title "'asciimat.dat' matrix index 0"
751 splot 'asciimat.dat' matrix index 0
754 set title "'asciimat.dat' matrix index 1"
755 splot 'asciimat.dat' matrix index 1
758 set title "'asciimat.dat' matrix index 2"
759 splot 'asciimat.dat' matrix index 2
762 set title "'asciimat.dat' matrix index 2 using 1:(2*$2):($3*$3)"
763 splot 'asciimat.dat' matrix index 2 using 1:(2*$2):($3*$3)
765 pause -1 "Hit return to continue"
769 print "Tux says \"bye-bye\"."
771 set xrange [-0.5:137.5]
772 set yrange [-0.5:137.5]
783 set view 60, 45, 1, 1
784 set label 1 "\"Mirror mirror on the wall,\nwho's the GNUiest penguin of all?\"" at 140,0,40 center
785 splot 'blutux.rgb' binary array=128x128 flip=y rot=90d origin=(0,0,0) perp = (1,0,0) format='%uchar' using ($1+$2+$3) with image, \
786 'blutux.rgb' binary array=128x128 flipy rot=90d origin=(+137,+137,0) perp=(0,1,0) format='%uchar' using ($1+$2+$3) with image
787 pause -1 "Hit return to continue"
791 print "End of image demo..."