Gnuplot Cookbook
Gnuplot Cookbook
Lee Phillips
BIRMINGHAM - MUMBAI
gnuplot Cookbook
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly
or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-84951-724-9
www.packtpub.com
Reviewers Proofreader
Andreas Bernauer Joanna McMahon
David Millán Escrivá
Indexers
Acquisition Editor Tejal Daruwale
Usha Iyer Hemangini Bari
Copy Editor
Laxmi Subramanian
About the Author
Lee Phillips grew up on the 17th floor of a public housing project on the Lower East Side of
Manhattan. He attended Stuyvesant High School and Hampshire College, where he studied
Physics, Mathematics, and Music. He received a Ph.D. in 1987 from Dartmouth in theoretical
and computational physics for research in fluid dynamics. After completing postdoctoral work
in plasma physics, Dr. Phillips was hired by the Naval Research Laboratory in Washington, DC,
where he worked on various problems, including the NIKE laser fusion project. Dr. Phillips is
now the Chief Scientist of the Alogus Research Corporation, which conducts research in the
physical sciences and provides technology assessment for investors.
David Millán Escrivá was 8 years old when he wrote his first program on 8086 PC with
Basic language. He has more than 10 years of experience in IT. He has worked on computer
vision, computer graphics, and pattern recognition. Currently he is working on different
projects about computer vision and AR.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt’s online digital book
library. Here, you can access, read and search across Packt’s entire library of books.
Why Subscribe?
ff Fully searchable across every book published by Packt
ff Copy and paste, print and bookmark content
ff On demand and accessible via web browser
ii
Table of Contents
iv
Preface
Why gnuplot?
gnuplot is a free, open source plotting program that has been in wide use since 1986.
It's used as the graphics backend by many other programs, so plenty of people use gnuplot
without knowing it. If you've used Octave, Maxima, statist, gretl, or the Emacs graphing
calculator, you've already used gnuplot.
gnuplot was originally designed to visualize scientific data, but its use has expanded to
encompass every domain where sophisticated and accurate plotting is required. gnuplot
is used in science, engineering, sociology, mapping, business, finance, and computer
systems and network monitoring.
gnuplot excels at complex 3D graphing with hidden-line removal and at the rendering
of surfaces and contours. It can produce almost any type of graph imaginable (except for
pie-charts—but it can be convinced to do this, too, as we'll show later!) for a dizzying array
of output devices, and can save plots in almost any type of common file format (and some
uncommon ones). It can be installed on any type of computer system you are likely to
encounter; there are binaries available for Windows and the sources can be compiled on
most reasonably modern machines. I have compiled the latest version (4.4) of gnuplot on
both Linux and Macintosh (OS X) computers and verified that all of its advanced features are
fully available on both of these architectures. The recipes in this book that illustrate features
newly appearing in version 4.4 are marked with [new].
gnuplot can easily be automated. It has its own scripting language and can be controlled from
many general-purpose programming languages. gnuplot can also be incorporated into various
publishing and document creation workflows to help create professional books, papers, and
online documents.