Gnuplot Question:
Download Questions PDF

How to print out graphs in Gnuplot?

Answer:

The kind of output produced is determined by the set terminal command; for example, set terminal postscript will produce the graph in PostScript format. Output can be redirected using the set output command.

As an example, the following prints out a graph of sin(x) on a Unix machine running the X-Window System.

gnuplot> plot [-6:6] sin(x)
gnuplot> set terminal postscript
Terminal type set to 'postscript'
Options are 'landscape monochrome "Courier" 14'
gnuplot> set output "sin.ps"
gnuplot> replot
gnuplot> set output # set output back to default
gnuplot> set terminal x11 # ditto for terminal type
gnuplot> ! lp -ops sin.ps # print PS File (site dependent)
request id is lprint-3433 (standard input)
lp: printed file sin.ps on fg20.rz.uni-karlsruhe.de (5068 Byte)
!
gnuplot>

Using the platform-independent way of restoring terminal by set term push/pop commands, do it by

gnuplot> set terminal postscript eps color lw 15 "Helvetica" 20
gnuplot> set out 'a.eps'
gnuplot> replot
gnuplot> set term pop

The command set term pop without a previous corresponding set term push switches the terminal back to the startup terminal, e.g. x11, pm or win.

In MS Windows you can click in the upper left corner of the graph window and print directly from there.

Download Gnuplot Programming Interview Questions And Answers PDF

Previous QuestionNext Question
Can we animate graphs in Gnuplot?How to generate plots in GIF format?