concept output in category gnuplot

appears as: output, output
Gnuplot in Action

This is an excerpt from Manning's book Gnuplot in Action.

But to export a graph to a file, you need to employ a file-based terminal that can generate output in the desired output format (PNG, PDF, SVG, and so on). Most file-based terminals accept a large number of options through which you can control various aspects (such as the size) of the resulting graph. These options are covered in detail in chapter 10.

1
2
3
4
set terminal pngcairo set output "| convert - graph.gif" plot sin(x) set output
Figure 10.2. Output produced when various free fonts are requested on my computer—your version may look different. The first part of the test string contains a selection of characteristic regular characters, and the second part consists of common mathematical symbols and Greek letters.
Gnuplot in Action: Understanding Data with Graphs

This is an excerpt from Manning's book Gnuplot in Action: Understanding Data with Graphs.

Listing 2.2. The complete workflow to generate a PNG file from gnuplot
plot exp(-x**2)              # some plot command set terminal png             # select the file format set output "graph.png"       # specify the output filename replot                       # repeat the most recent plot command,                              #   with the output now going to the                              #   specified file. set terminal x11             # restore the terminal settings set output                   # send output to the screen again,                              #   by using an empty filename.

This example demonstrates an important point: after exporting to a file, gnuplot does not automatically revert back to interactive mode—instead, all further output will be directed to the specified file. Therefore, we need to explicitly restore the interactive terminal (x11 in this example) and the output device. (The command set output without an argument sends all output to the interactive device, usually the screen.) This should come as no surprise. As we’ve seen before, gnuplot remembers any previous settings, and so neither the terminal nor the output setting change until we explicitly assign them a different value.

Figure 10.10. A noisy data set and a best fit curve. See listing 10.8 for the output of the fit command.
Listing 12.1. Script to export a plot to a PNG file with a watermark
save "$0.gp"    # save the current commands to file w/o watermark watermark = "File $0.png - Generated by `whoami` at `date`"; set label 9999 watermark at screen 0.02,0.02 font "FreeSans, 6" set bmargin 3   # increase bottom margin to make room for watermark set t push      # save the current terminal settings set t png font "FreeSans, 11" # change terminal to PNG,                               #     choosing a decent font set o "$0.png"  # set the output filename to the first option replot          # repeat the most recent plot command set o           # restore output to interactive mode set t pop       # restore the terminal watermark = ''  # revert to previous state... unset label 9999 unset bmargin

In general, the system() function is more versatile than back ticks, and the preferred way to capture output from a subprocess. But back ticks have the advantage that they can occur inside of double-quoted strings, whereas the output from the system() function would have to be concatenated explicitly to the string. In other words, the following two commands are equivalent:

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest