LaTeX - Multidimensional time series PGFPlots tikzpicture

I am working on my bachelor thesis and have to deal with multidimensional time series. Quite specifically time series containing acceleration data from the three sensors produced by a Wii controller. I would like to show on a small example how I represent multidimensional time series graphs in LaTeX.

Data file

I start with the data file. The file contains a table with four columns. On the first column the time in integers starting with 1. The second column is the x axis, the third is the y and the fourth is the z. Row number one are just the titles of the columns. I saved the file with the name timeseries.dat.

t x y z
1 2 3 7
2 1 2 8
3 0 0 8
4 2 0 10
5 3 0 11
6 2 -1 12
7 2 -1 12
8 2 -1 13
9 -1 -1 13
10 -2 -2 13
11 -4 -2 13
12 -4 -2 12
13 -5 -2 12
14 -5 -2 11
15 -5 -2 11
16 -6 -2 11
17 -6 -3 10
18 -6 -3 9
19 -5 -3 8
20 -5 -3 7
21 -5 -3 6
22 -4 -3 6
23 -2 -3 5
24 -2 -3 5
25 -2 -4 6
26 -1 -4 5
27 0 -3 5
28 1 -3 6
29 1 -3 6
30 1 -3 6
31 2 -3 7
32 2 -3 7
33 2 -3 7
34 2 -3 8
35 3 -2 8
36 2 -2 9
37 2 -3 10
38 3 -2 10
39 3 -2 11
40 1 -2 11
41 2 -2 11
42 2 -1 12
43 2 -1 12
44 2 -1 12
45 2 -1 12
46 1 -1 12
47 -1 -1 12
48 -1 -1 12
49 -1 -1 12
50 -2 -1 11
51 -3 -2 11
52 -3 -2 11

Plot time series data

The following tex file plots the multidimension time series data to a graph. The x axis is blue, the y axis red and the z axis is green.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[xlabel=time, ylabel=accel, legend pos=outer north east]
            \addplot[blue, mark=none] table[x=t, y=x] {timeseries.dat};
            \addlegendentry{x}
            \addplot[red, mark=none] table[x=t, y=y] {timeseries.dat};
            \addlegendentry{y}
            \addplot[green, mark=none] table[x=t,y=z] {timeseries.dat};
            \addlegendentry{z}
        \end{axis}
    \end{tikzpicture}
\end{document}

The result should look like this.

LaTeX PGFPlots tikzpicture time series
Next Previous