### Sidebar

spatial-ecology.org

Trainings:

Learn:

Data:

Community:
teachers
students
projects
Matera 2015
Vancouver 2015
Santa Barbara 2015
Site design
Hands on:
Installations

Donations
USD

GBP

wiki:gnuplotsintax

# The Gnuplot syntax

Exercise:

## The gnuplot commands

The most important commands can grouped in two operations:

• Setting the plotting environment by: set command.
• Plotting the data by: plot and splot commands.

Syntax:

```     plot {<ranges>}
{<function> | {"<datafile>" {datafile-modifiers}}}
{axes <axes>} {<title-spec>} {with <style>}
{, {definitions,} <function> ...}```

Here we will concentrate on commands for plotting data in 2D and 3D.

Enter in gnuplot by:

`gnuplot`

Plot standard function:

`plot sin (x) 		`

`plot 'input.txt'   u 3:4 `

Query your data by AWK language:

`plot "<awk '{if(\$2==2007) print \$0 }'  input.txt " u 4:5`

Plot two series of data in one plot:

`plot "<awk '{if(\$2==2007) print \$0 }'  input.txt " u 4:5, "<awk '{if(\$2==2005) print \$0 }'  input.txt " u 4:5,`

Sampling your data by AWK language:

```# 2D plot
plot "<awk '{if (NR%100== 0) print \$0}' aver_month_nuts3.asc " u 4:5
# 3D plot
splot "<awk '{if (NR%100== 0) print \$0}' aver_month_nuts3.asc " u 4:5:7```

Query your data by bash commands:

`plot "< grep 2005  input.txt " u 4:5`

Run a bash command inside gnuplot using the symbol !

`! head input.txt`

```shell