- not so Frequently Asked Questions -
not so FAQ
An image format that gnuplot can generate directly is ppm and png. Gnuplot ver.3.7 can make a GIF too. But the GIF file generated by gnuplot is not compressed because of a LZW patent problem, then the file size is usually very large. In addition GIF is no more supported by gnuplot3.8. Main reasons of use of GIF are to put the graph into your Web pages. If so, you can use PNG (Portable Network Graphics) too, as many browsers are capable of displaying the PNG files, and usually the size of PNG file is smaller than GIF.
There are several ways of image format conversion. Here are some examples.
Netpbm (ppmtoXXX commands) is useful for automatic conversion. The screen dump method with xwd is probably the easiest way.
Firstly display something with gnuplot, then dump that window with xwd.
gnuplot> set yrange [-6:6] gnuplot> set hidden3d gnuplot> set isosample 40 gnuplot> splot x*sin(y) gnuplot> shell % xwd > screen.xwd % exit exit gnuplot>
Open this "screen.xwd" with xv, Imagemagick (display command), or Gimp, and save it in a image format like PNG. Otherwise, with netpbm
% xwdtopnm < screen.xwd | ppmtopng > screen.png
This generates PNG too. The next PNG figure was made with this technique.
With GhostScript you have to check what image formats your gs supports first. This can be done with the --help option of gs.
% gs -help GNU Ghostscript 5.10 (1998-12-17) Copyright (C) 1997 Aladdin Enterprises, Menlo Park, CA. All rights reserved. Usage: gs [switches] [file1.ps file2.ps ...] Most frequently used switches: (you can use # in place of =) -dNOPAUSE no pause after page | -q `quiet', fewer messages -g<width>x<height> page size in pixels | -r<res> pixels/inch resolution -sDEVICE=<devname> select device | -dBATCH exit after last file -sOutputFile=<file> select output file: - for stdout, |command for pipe, embed %d or %ld for page # Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PDF Available devices: x11 x11alpha x11cmyk x11gray2 x11mono ml600 npdl epag escpage lbp310 lbp320 lips2p lips3 lips4 lips4c lips4v lips4vc fmpr mjc180 mjc360 mjc720 mj500c pr150 jj100 bj10v bj10vh md5000 dmprt deskjet djet500 laserjet .....
Here is an explanation how to convert a PS file into jpeg with gs. First, you make an EPS file with gnuplot, then convert it with gs.
% gs -dNOPAUSE -sDEVICE=jpeg -sOutputFile=test.jpg -q -dBATCH -g500x350 test.eps
The command above should not be folded but in one-line. The -sOutputFile specifies the output file name. When -sOutputFile=- , the output goes to STDOUT. The -g option means the pixel size of image, which depends on the figure size in the EPS file.
The JPEG format, as shown below, is mainly used for a photo image, and it is not suitable for images which have strong contrast at borders. To show a graph in a image format, GIF and PNG are better than JPEG