Tutorial

This is a basic tutorial for people who have no experience with gnuplot.

Tutorial: The Basics

How to plot a function?

Plotting functions is easy:

``````plot sin(x)
``````

Functions are always working with the variable x. There are a lot of built in functions that you can use to draw almost any mathematical function:

• abs(x)
• acos(x)
• arg(x)
• asin(x)
• atan(x)
• besj0(x)
• besj1(x)
• besy0(x)
• besy1(x)
• ceil(x)
• cos(x)
• cosh(x)
• erf(x)
• erfc(x)
• exp(x)
• oor(x)
• gamma(x)
• ibeta(p,q,x)
• igamma(a,x)
• imag(x)
• int(x)
• lgamma(x)
• log(x)
• log10(x)
• rand(x)
• real(x)
• sgn(x)
• sin(x)
• sinh(x)
• sqrt(x)
• tan(x)
• tanh(x)

Plotting multiple functions in the same plot is easy:

``````plot sin(2*x*pi), cos(2*x*pi - pi/2)-1, tan(2*x*pi)
``````

How to change the axis?

Axis are usually autoscaled but if you want to manually change them, there are two possibilities:

``````#This is the easiest way, but it only applies to single plots
plot [0:2*pi] sin(x)

#Globally changes the scaling of the x axis;
set xrange [0:2*pi]
set yrange [-1:1]
plot cos(x)
``````

To get back the autoscaling, use:

``````set autoscale
plot sin(x)
``````

Sometimes you want to change the ticks on the axis. This can be modifed by:

``````set xtics 10
set ytics 10
``````

To set the name of the axis in a plot, use:

``````set xlabel 'Some name'
set ylabel 'Other name'
``````

How to change the look of data points and lines?

Gnuplot offers line and point styles that you can use to modify the look of your graphs. The following is an example that will show some of the features that can be introduced by the with statement:

``````plot sin(x) with linespoints linewidth 2
``````

Features:

lines, points, linespoints, impulses, dots, steps, errorbars (or yerrorbars), xerrorbars, xyerrorbars, boxes, boxerrorbars, or boxxyerror-bars

Changes the way the data points are displayed. You can have isolated points or points that are linked by lines, if you have a third data row for errors, you can use errorbars. For histograms you can use boxes and so on...

``````plot sin(x) with linewidth (width)
``````

Sets the linewidth of line plots.

``````plot sin(x) with linestyle 1
``````

Sets the style of the line. Look at the following Gnuplot Test Screen to see which values belong to which styles.

You can use various fonts within your plot. For example, to set a label with a different font, you use:

``````set xlabel 'Temperature [K]' font 'Arial, 20'
``````

The following open-source fonts are available:

Arial, Arial_Bold, Arial_Bold_Italic, Arial_Italic, Comic_Sans_MS, Comic_Sans_MS_Bold, Courier_New, Courier_New_Bold, Courier_New_Bold_Italic, Courier_New_Italic, Georgia, Georgia_Bold, Georgia_Bold_Italic, Georgie_Italic, Impact, Times_New_Roman, Times_New_Roman_Bold, Times_New_Roman_Bold_Italic, Times_New_Roman_Italic, Trebuchet_MS, Trebuchet_MS_Bold, Trebuchet_MS_Bold_Italic, Trebuchet_MS_Italic,Verdana, Verdana_Bold, Verdana_Bold_Italic, Verdana_Italic, Webdings\

The following picture contains information about the available styles:

How to change the legends?

``````Will come soon...
``````

Tutorial: How to plot YOUR data?

You can upload any external data up to 3 MB each, limited to 5 external Data Files. The use of external data is pretty straight forward:

``````plot ExtData1 using 1:3
``````

The ExtData1 is the name of the external data field you have copied your data into. With the help of the using command, you can chose, which column to use for the x-values and which for the y-values.

If your data columns are NOT separated by whitespaces, you have to specify a seperator, e.g.:

``````set datafile separator ","
``````

Tutorial: Fitting Data

A quick introduction to function fitting will follow shortly.

Tutorial: Multiplot

Multiplot functionality still has to be implemented...