Edit:
The original question was answered by @James and his solution covers the particular problem presented here.
In This question I have exposed the original problem and I have received answer to the points 1, 2 and 4, but not the 3th.
Inspired in the answer given by Carina I started to work in some solution, but it is still not 100% right.
Based on this meta I have decided to post a sub-question to refine the definitive answer and put it on the original post for the posterity.
The (remaining) problem
- To make the sections* and put the labels on they (in the spaces, not the lines), @Carina gave me some good ideas, but I need something a little more advanced, the idea is that those lines continues below the X labels.
- To get the values for the section separator lines from an external file (as is done with the stacked area plots).
("sections" are those vertical slices or partitions of the X axis seen in the picture. If X is time, they can be understood as consecutive "periods of time")
The partial answer
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\usepackage{filecontents}
\begin{filecontents}{data.txt}
Time core1 core2 core3 core4 mem
0 7.847 19.51 18.389 18.943 400.90
1 6.863 64.706 12.871 30 913.50
2 10 88 0 0 1215.19
3 57.576 39 0 0 1691.61
4 0.99 99 0.99 0 1694.64
5 0 40.594 60 0 1698.15
6 0 96.939 3.03 0 1699.55
7 0 50.495 48.515 0 1700.09
8 0.99 53 47 0 1703.00
9 0 28.283 69 3 1696.77
10 31.313 0 0 67.677 1697.30
11 15 84 1.01 2.941 2252.78
12 0 15 14.141 71.717 2249.72
13 31 27 6.931 37 2249.00
14 2 13.725 60.606 28 2248.16
15 9 34.343 41 19 2248.31
16 32 41.414 25.743 0 2250.18
17 26 33.663 20.408 21 2249.89
18 23 13 40 25.253 2249.89
19 47.525 18.182 22 12.121 2249.60
20 34.694 25.253 22.772 16.832 2249.32
21 22 0.99 42.574 37.374 2249.01
22 12.871 24 12.121 56.436 2251.39
23 17.172 15.152 49.02 20.202 2252.57
24 27 5.051 32.653 36 2252.72
\end{filecontents}
\begin{filecontents}{data2.txt} % For now, I'm not using this file
steps
0
0.024
10.127
10.143
21.634
24.81
\end{filecontents}
\begin{document}
\begin{tikzpicture}[scale=1]
\begin{axis}[
axis y line=left,
axis x line=bottom,
enlarge x limits=0,
enlarge y limits=0,
width=15cm,
height=8cm,
stack plots=y,
area style,
xlabel={Time},
ylabel={CPU usage},
ymax=500
]
\foreach \i in {1,...,4}{
\addplot table [y index=\i]{data.txt} \closedcycle;
}
\end{axis}
\begin{axis}[
axis y line=right,
axis x line=none,
enlarge x limits=0,
enlarge y limits=0,
width=15cm,
height=8cm,
fill=none,
ymax=7600
]
\addplot[very thick,draw=green] table[y index=5]{data.txt};
% The separators are written manually and there is no label
\draw[black](axis cs: 0.024,0)--(axis cs: 0.024,8000);
\draw[black](axis cs: 10.127,0)--(axis cs: 10.127,8000);
\draw[black](axis cs: 10.143,0)--(axis cs: 10.143,8000);
\draw[black](axis cs: 21.634,0)--(axis cs: 21.634,8000);
\draw[black](axis cs: 24.810,0)--(axis cs: 24.810,8000);
\end{axis}
\end{tikzpicture}
\end{document}
Some gimp to show the desired output
(Please notice that the steps 1 and 3 are really short, so they seems like a single line but they are two)
Thanks a lot for your time :)
\pgfplotsset{compat=1.13}
. By this you can simplified notations of coordinates (see pgfplots manual), theaxis cs:
is not necessary anymore.