Gnuplot - Introduction

Plotting and Graphical Data Analysis

Part 1 : Introduction

Motivation

Can’t I just use Excel?

Yes, yes you can.

But…

This animated gif was created using gnuplot and the convert command

we can script Gnuplot!!

And:

Getting Started

$ apt search gnuplot
$ apt search gnuplot-x11
...
$ apt install gnuplot-x11
[sudo] password for rshackleford:

Plotting Data

gnuplot> plot 'example.txt'

Demo : Introduction

./demos/01-intro.sh

Part 2 : Plotting Data

plot Command

The plot command takes 1 or more arguments, which take one or more options

gnuplot> plot 'example.txt', 'multi-column.txt'

options:

Demo : Plot Options

./demos/02-plot_options.sh

Part 3 : Plotting Functions

plotting functions

Functions and Operations:

plotting functions

You can also define your own functions:

gnuplot> f(x) = 10*x + 2
gnuplot> plot f(x)
gnuplot> g(t) = 2*t - 9.8*t**2 / 2
gnuplot> plot g(x)

Demo : plotting functions

./demos/03-plotting_functions.sh

Part 4 : Scripts

scripts

Gnuplot reads command from the command line. It can also read commands from a file.

gnuplot> load "plot-data.txt"

Demo : scripts

./demos/04-scripts.sh

Part 5 : Saving Images

Creating images

Demo : Creating images

./demos/05-images.sh

Plot settings

Demo : Plot settings

./demos/06-settings.sh

Transforming Columns

gnuplot> plot 'data.txt' using 1:($2*$2)
gnuplot> plot 'data.txt' using ($1-10):($1*$2)

\(P = i^2 R\)

Demo : Column Transformations

./demos/07-column_transform.sh

Part 6: Variables

Variables

gnuplot> m = 2
gnuplot> print m
2
gnuplot> plot m*x

Part 8: Error Bars

Error bars

gnuplot> plot 'data.txt' with yerrorbars
gnuplot> plot 'data.txt' with xerrorbars
gnuplot> plot 'data.txt' with xyerrorbars

Demo : Error bars

./demos/11-error_bars.sh

Example 1: Torque and Horsepower

Note:

1 lbf = 4.448 N

1 m = 3.28 ft

1 hp = 745 W

\(1\;\text{ft}\cdot\text{lbf}\;\times\;1\;\text{rpm} =1\;\frac{\text{ft}\cdot\text{lbf}\;\text{rev}}{\text{min}}\)

\(1\;\frac{\text{ft}\cdot\text{lbf}\;\text{rev}}{\text{min}} \frac{2\pi\;\text{rad}}{\text{rev}} \frac{4.448\;\text{N}}{\text{lbf}} \frac{\text{m}}{3.28 \text{ft}} \frac{\text{min}}{60\;\text{s}} \frac{\text{hp}}{745\;\text{W}} = 0.00019 \; \text{hp} = \frac{1}{5252} \text{hp}\)