next up previous contents index
Next: On-Screen Plots Up: plt Tutorial and Cookbook Previous: Using plt with pdfLATEX


Preparing Plots for the Web

Using the lwcat postprocessor described in appendix B, you can easily prepare plots in PDF or PNG format for publication on the Web. PNG format is one of only three graphics formats that are viewable by all current graphics-capable web browsers (the others are GIF, which produces inferior results and is proprietary, and JPEG, which is designed for continuous-tone photographs and is unsuitable for line drawings).

Unlike PNG, PDF is a vector format, so that PDF plots can be magnified to view fine detail. Both open-source and proprietary (but freely available) PDF viewer plugins are available for many web browsers, but not everyone has installed a PDF plugin, and viewing PDF images is usually noticeably slower (because of the overhead involved in loading the plugin and rasterizing the image) than viewing PNG images.

Use lwcat as described in the previous appendix, with the option -png or -pdf to write PNG or PDF format to the standard output. Usually you will wish to capture the file by redirecting the standard output, as in these examples:

plt -T lw ... | lwcat -png >output.png
plt -T lw ... | lwcat -pdf >output.pdf

To prepare PDF output, lwcat uses epstopdf (freely available from CTAN, http://www.ctan.org/), a perl script that translates the PostScript generated by plt using GhostScript, a free PostScript renderer that runs on a vast variety of operating systems. If you have followed the instructions for installing plt on your system, you should have GhostScript already; if not, get it from http://ghostscript.com/. If you need perl, you can get it from CPAN, http://www.cpan.org/.

To prepare PNG output, lwcat uses pltpng, a tiny shell script included with plt. pltpng in turn uses convert, a utility included in ImageMagick, a free set of image-processing tools and libraries that also runs on all popular operating systems. Most GNU/Linux distributions include ImageMagick, which is also available for other versions of Unix as well as Mac OS X and MS-Windows; if you don't have it already, get it from http://www.imagemagick.org/.

It's easy to add support for generating any of the other image formats (over 90 of them, as of April 2005) supported by convert. Use pltpng as a model, and add an option for the desired format to lwcat.


next up previous contents index
Next: On-Screen Plots Up: plt Tutorial and Cookbook Previous: Using plt with pdfLATEX
George B. Moody (george@mit.edu)
2005-04-26