Skip to Content
Feedback Control for Computer Systems
book

Feedback Control for Computer Systems

by Philipp K. Janert
October 2013
Intermediate to advanced content levelIntermediate to advanced
330 pages
7h 46m
English
O'Reilly Media, Inc.
Content preview from Feedback Control for Computer Systems

Appendix B. Creating Graphs with Gnuplot

Gnuplot is an open source program for plotting data and functions. It is intended primarily for Unix/Linux systems, although versions for Windows and the Mac exist as well.

Basic Plotting

When started, gnuplot provides a shell-like interactive command prompt. All plotting is done using the plot command, which has a simple syntax. To plot a function, you would type (at the gnuplot prompt):

plot sin(x)

By default, gnuplot assumes that data is stored in white-space separated text files, with one line per data point. To plot data from a file (residing in the current directory and named data), you would use the following:

plot "data" using 1:2 with lines

This assumes that the values used for the horizontal position (the x values) are in the first column, and the values for the vertical position (the y values) are in the second column. Of course, any column can be used for either x or y values.

Gnuplot makes it easy to combine multiple curves on one plot. Assume that the data file looks like the one shown in Figure B-1 (left). Then the following command would plot the values of both the second and the third column, together with a function, in a single graph (Figure B-1, right):

plot "data" u 1:2 w lp, "data" u 1:3 w lp, 5*exp(-5*x)

Here we have made use of the fact that many directives can be abbreviated (u for using and w for with) and have also introduced a new plotting style, linespoints (abbreviated lp), which plots values as symbols connected by lines. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Control Systems

Control Systems

William Bolton

Publisher Resources

ISBN: 9781449362638Errata PageSupplemental Content