Table of Contents

GnuPlot

Enter gnuplot environment with 'gnuplot' command. In the interactive shell you can use the following commands.

load

To load a command file, which contains other commands for the gnuplot interactive shell. Lines starting with '#' are ignored.

load "plot_data.gp"

You can also directly load it when starting gnuplot, in shell:

gnuplot -persist plot_data.gp

If the file ends with “pause -1”, you can omit the “-persist” argument.

set

plot

Plot functions

FIXME

Plot data from a file

File outputs

In general be sure that you don't have another “set term” command in your plotting code.

Interactivity

Example

This is a typical example that uses the most useful features to plot data from a file. It is easy to copy and adapt for your own use.

set term wxt size 1024,768
 
# file to plot:
file="rtslam.log"
 
# to have smaller crosses:
set pointsize 0.3333333333333
 
# to have the same scale along x and y axis:
#set size ratio -1
 
# to display a grid:
#set grid
 
# to have a different right y axis:
set y2tics auto
set ytics nomirror
 
# titles
set title "Accelerometer biases and g estimation"
set xlabel "Time (s)"
set ylabel "Acceleration (m/s2)"
set y2label "Angle (deg)"
 
# to define some functions:
norm3(x,y,z)=sqrt(x*x+y*y+z*z)
pitch(x,y,z) = atan2(-x, z)*180/pi
roll(x,y,z) = atan2(y, z)*180/pi
 
# to define some variables:
t0=1281469302
 
# now plot:
plot \
    file using ($1-t0):15 with points pt 1 lt rgb "red"       title "Bias AX", \
    file using ($1-t0):16 with points pt 1 lt rgb "dark-red"  title "Bias AY", \
    file using ($1-t0):17 with points pt 1 lt rgb "orange"    title "Bias AZ", \
    file using ($1-t0):(norm3($21,$22,$23)/100)           with points pt 1 lt rgb "blue"       title "Norm g / 100", \
    file using ($1-t0):(pitch($21,$22,$23))     axes x1y2 with points pt 1 lt rgb "green"      title "Pitch g", \
    file using ($1-t0):(roll($21,$22,$23))      axes x1y2 with points pt 1 lt rgb "dark-green" title "Roll g"
 
 
# prevent window from closing at the end
pause -1