Gnuplot in Action, Second Edition
Understanding data with graphs
Philipp K. Janert
  • March 2016
  • ISBN 9781633430181
  • 400 pages
  • printed in black & white

The highly anticipated, updated version of my go-to-for-everything book on gnuplot.

Ryan Balfanz, Shift Medical, Inc.

Gnuplot in Action, Second Edition is a major revision of this popular and authoritative guide for developers, engineers, and scientists who want to learn and use gnuplot effectively. Fully updated for gnuplot version 5, the book includes four pages of color illustrations and four bonus appendixes available in the eBook.

Table of Contents detailed table of contents



about this book

about the authors

author online

about the cover illustration

Part 1 Getting started

1. Prelude: Understanding data with gnuplot

1.1. A busy weekend

1.1.1. Planning a marathon

1.1.2. Determining the future

1.2. What is graphical analysis?

1.2.1. Why graphical analysis?

1.2.2. Limitations of graphical analysis

1.3. What is gnuplot?

1.3.1. Gnuplot isn’t GNU

1.3.2. Why gnuplot?

1.3.3. Limitations

1.3.4. Gnuplot 5: the best gnuplot there ever was!

1.4. Summary

2. Tutorial: Essential gnuplot

2.1. Simple plots

2.1.1. Invoking gnuplot and first plots

2.1.2. Plotting data from a file

2.1.3. Abbreviations and defaults

2.2. Saving commands and exporting graphics

2.2.1. Saving and loading commands

2.2.2. Exporting graphs

2.2.3. One-step export script

2.3. Managing options with set and show

2.4. Getting help

2.5. Summary

3. The heart of the matter: the plot command

3.1. Plotting functions and data

3.1.1. Plotting functions

3.1.2. Plotting data

3.2. Math with gnuplot

3.2.1. Mathematical expressions

3.2.2. Built-in functions

3.2.3. User-defined variables and functions

3.2.4. functions

3.2.5. Mathematically undefined values and NaN (Not-a-Number)

3.3. Data transformations

3.3.1. Simple data transformations

3.4. Logarithmic plots

3.4.1. Digression: How do logarithmic plots work?

3.5. Smooth interpolation and approximation

3.5.1. Interpolation curves

3.5.2. Point distributions

3.5.3. Deduping repeated entries

3.6. Summary

Part 2 Creating graphs

4. Managing data sets and files

4.1. Quickstart: The standard data file format

4.1.1. Comments and header lines

4.1.2. Selecting columns

4.2. Managing structured data sets

4.2.1. Multiple data sets per file: index

4.2.2. Records spanning multiple lines: every

4.3. File format options in detail

4.3.1. Number formats


4.3.3. Field separator

4.3.4. Missing values

4.3.5. Strings in data files

4.4. Accessing columns and pseudocolumns

4.4.1. Accessing columns by position or name

4.4.2. Pseudocolumns

4.4.3. Column access functions

4.5. Pseudofiles

4.5.1. Reading data from standard input

4.5.2. Heredocs

4.5.3. Reading data from a subprocess

4.5.4. Writing to a pipe

4.5.5. Generating data

4.6. Metadata in data files

4.7. Other file formats

4.8. Summary

5. Practical matters: strings, loops, history

5.1. Strings


5.1.2. String operations

5.1.3. String applications

5.1.4. Crazy example: plotting the Unix password file

5.1.5. Digression: Unicode and UTF-8

5.2. String macros

5.3. Generating textual output

5.3.1. The print command

5.3.2. The set table option

5.4. Simplifying work with inline loops

5.4.1. Loops over numbers

5.4.2. Loops over strings

5.4.3. Summary of inline loops

5.5. Gnuplot’s internal variables

5.6. Inspecting compile-time options

5.7. Command history

5.7.1. Redrawing a graph

5.7.2. The general history feature

5.7.3. Restoring session defaults

5.8. Summary

6. A catalog of styles

6.1. Why use different plot styles?

6.2. Styles and aspects

6.2.1. Choosing styles inline through with

6.2.2. The default sequence

6.2.3. Customizing graph elements

6.3. A catalog of plotting styles

6.3.1. Core styles: lines and points

6.3.2. Indicating uncertainty: styles with errorbars or ranges

6.3.3. Styles with steps and boxes

6.3.4. Filled styles

6.3.5. Beyond lines and points: multivariate visualization

6.4. Putting it together

6.5. Other styles

6.6. Summary

7. Decorations

7.1. Quick start: minimal context for data

7.2. Digression: layers and locations

7.2.1. Locations

7.2.2. Layers

7.3. Additional graph elements: decorations

7.3.1. Common conventions

7.3.2. Arrows

7.3.3. Text labels

7.3.4. Shapes or "Objects"

7.4. The graph’s legend or key

7.4.1. Turning the key on and off

7.4.2. Placement

7.4.3. Layout

7.4.4. Appearance

7.4.5. Explanations

7.4.6. Default settings

7.5. Worked example: features of a spectrum

7.6. Summary

8. All about axes

8.1. Multiple axes

8.1.1. Terminology

8.1.2. Plotting with two coordinate systems

8.1.3. Sidebar: Should you do it?

8.1.4. Linking axes

8.2. Selecting plot ranges

8.2.1. What you need to know for interactive work

8.2.2. What you might want to know for batch processing

8.3. Tic marks

8.3.1. Overview and common conventions

8.3.2. Tic mark appearance and placement

8.3.3. Tic labels

8.3.4. Tic mark location and frequency

8.3.5. Reading tic labels from file

8.3.6. Grid and zero axis

8.4. Special case: Time series

8.4.1. Digression: Locales

8.4.2. Turning numbers into names: months and weekdays

8.4.3. General time series: the gory details

8.4.4. Beyond tic labels: processing date/time information

8.5. Summary

Part 3 Mastering technicalities

9. Color, style, and appearance

9.1. Color

9.1.1. Explicit colors

9.1.2. Alpha shading and transparency

9.1.3. Selecting a color through indexed lookup

9.1.4. Mapping a value into a continuous gradient

9.1.5. Using data-dependent colors

9.1.6. The built-in color sequences

9.1.7. Tips and tricks

9.2. Lines and points

9.2.1. Point types and shapes

9.2.2. Dash pattern

9.3. Customizing color, dash, and point sequences

9.3.1. Customizing line types

9.3.2. Special line types

9.4. Global styles

9.4.1. Data and function styles

9.4.2. Line styles

9.4.3. Arrow styles

9.4.4. Fill styles

9.4.5. Other global styles

9.5. Overall appearance: aspect ratio and borders

9.5.1. Size and aspect ratio

9.5.2. Borders

9.5.3. Margins

9.5.4. Internal variables

9.6. Summary

10. Terminals in depth

10.1. The terminal abstraction

10.1.1. Historical digression

10.1.2. The terminal workflow

10.1.3. Terminal capabilities and the test command

10.1.4. Gnuplot terminals today

10.2. Font selection and enhanced text mode

10.2.1. Font selection

10.2.2. Font resolution

10.2.3. Enhanced text mode

10.3. Generating PNG and PDF with Cairo-based terminals

10.3.1. Scaling a complete plot up or down

10.4. Using gnuplot with LaTeX

10.4.1. Including a graph in a LaTeX document

10.4.2. Using the cairolatex terminal

10.4.3. Letting LaTeX generate the graph

10.5. Scalable graphics for the Web with SVG and HTML5

10.5.1. The svg terminal

10.5.2. The canvas terminal

10.6. Interactive terminals

10.6.1. Common options

10.6.2. The wxt and qt terminals

10.6.3. Aqua

10.6.4. Windows

10.7. Other terminals

10.8. Summary

11. Automation, scripting, and animation

11.1. Loops and conditionals

11.1.1. Worked example: making graph paper

11.1.2. Worked examples: iterating over files

11.1.3. Worked examples: Taylor series and Newton’s method

11.2. Command files

11.2.1. Scripts as subroutines

11.2.2. Worked example: export script

11.3. Batch processing

11.3.1. Using gnuplot in shell pipelines

11.4. Calling gnuplot from other programs

11.4.1. Worked example: calling gnuplot from Perl

11.4.2. Worked example: calling gnuplot from Python

11.4.3. Helpful hints

11.5. Animations

11.5.1. Introducing a delay

11.5.2. Waiting for a user event

11.5.3. Further examples

11.6. Case study: continuously monitoring a live data stream

11.6.1. Using gnuplot to monitor a file

11.6.2. Using a driver to monitor arbitrary data sources

11.7. Summary

12. Beyond the defaults: workflow and styles

12.1. The standard interactive workflow

12.1.1. Extracting specifics from command files

12.1.2. Extending the command set

12.1.3. Session variables, loops, and macros

12.2. Using external editors and viewers

12.3. Invoking shell commands from gnuplot

12.3.1. Worked example: plotting each file in a directory

12.4. Hot keys and mousing

12.4.1. Default hot keys

12.4.2. Mousing

12.4.3. Custom hot keys

12.4.4. Capturing mouse events

12.4.5. Case study: placing arrows and labels with the mouse

12.5. Startup configurations and initialization

12.5.1. Startup and initialization files

12.5.2. Environment variables

12.5.3. Gnuplot command-line flags

12.6. Stylesheets

12.6.1. Worked example: stylesheets

12.7. Summary

Part 4 Understanding data

13. Basic techniques of graphical analysis

13.1. Representing relationships

13.1.1. Scatter plots

13.2. Logarithmic plots

13.2.1. Large variations in data

13.2.2. Power-law behavior

13.3. Point distributions

13.3.1. Summary statistics and box plot

13.3.2. Jitter plots and histograms

13.3.3. Kernel density estimates and rug plots

13.3.4. Cumulative distribution functions

13.4. Ranked data

13.5. Pie charts

13.6. Organizational issues

13.6.1. The lifecycle of a graph

13.6.2. Input data files

13.6.3. Output files

13.7. Presentation graphics

13.8. Summary

14. Topics in graphical analysis

14.1. Techniques for time-series plots

14.1.1. Plotting an Apache webserver log

14.1.2. Smoothing and differencing

14.1.3. Monitoring and control charts

14.1.4. Changing composition and stacked curves

14.2. Graphical techniques for multivariate data sets

14.2.1. Introduction

14.2.2. Distribution of values by attribute

14.2.3. Distribution by level

14.2.4. Scatter plot matrix

14.2.5. Parallel-coordinates plot

14.3. Visual Perception

14.3.1. Banking

14.3.2. Judging lengths and distances

14.3.3. Plot ranges and whether to always include zero

14.4. Summary

15. Coda: Understanding data with graphs


Appendix A: Obtaining, building, and installing gnuplot

Appendix B: Resources

The following bonus appendixes are available in the eBook

Appendix C: Surface and contour plots

Appendix D: Paletes and false-color plots

Appendix E: Special plots

Appendix F: Higher math

About the Technology

Gnuplot is an open-source graphics program that helps you analyze, interpret, and present numerical data. Available for Unix, Mac, and Windows, it is well-maintained, mature, and totally free.

About the book

Gnuplot in Action, Second Edition is a major revision of this authoritative guide for developers, engineers, and scientists. The book starts with a tutorial introduction, followed by a systematic overview of gnuplot’s core features and full coverage of gnuplot’s advanced capabilities. Experienced readers will appreciate the discussion of gnuplot 5’s features, including new plot types, improved text and color handling, and support for interactive, web-based display formats. The book concludes with chapters on graphical effects and general techniques for understanding data with graphs. It includes four pages of color illustrations. 3D graphics, false-color plots, heatmaps, and multivariate visualizations are covered in chapter-length appendixes available in the eBook.

What's inside

  • Creating different types of graphs in detail
  • Animations, scripting, batch operations
  • Extensive discussion of terminals
  • Updated to cover gnuplot version 5

About the reader

No prior experience with gnuplot is required. This book concentrates on practical applications of gnuplot relevant to users of all levels.

About the author

Philipp K. Janert, Ph.D, is a programmer and scientist. He is the author of several books on data analysis and applied math and has been a gnuplot power user and developer for over 20 years.

  • combo $44.99 pBook + eBook
  • eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

The essential guide for newcomers and the definitive handbook for advanced users.

Zoltán Vörös, University of Innsbruck

Learn how to use gnuplot to convert meaningful data into attention-grabbing visualizations that communicate your message quickly and accurately.

David Kerns, Rincon Research Corporation

An accessible guide to gnuplot and best practices of everyday data visualization.

Wesley R. Elsberry,PhD, RealPage, Inc.