I am working on an algorithm to minimize a function by iterative improvement, and I am plotting the function's value for each iteration (pretty straightforward plot). I am feeding GnuPlot or PgfPlots an input file like:
"Solution 1"
2.22419e+007
2.22418e+007
2.22418e+007
...
GnuPlot script:
set key autotitle columnheader
plot 'data.txt' with lines
PgfPlots script:
\begin{tikzpicture}
\begin{axis}[xlabel={Iteration}, ylabel={Solutions values}]
\addplot [blue] table[x expr=\coordindex, y index=0] {data.txt};
\end{axis}
\end{tikzpicture}
In my algorithm sometimes an event happens, namely I switch to another method for few iterations, or I have to relax some constraints because I can't get an improvement. I would like to show these events in the plot. I am looking for something like this (black vertical lines), but I am open to different alternatives as long as the meaning is the same:

What is the best way to show events in this kind of plots? How to do it with GnuPlot and PgfPlots?
Event Ahas happened at such and such anxvalue? If you record that information in a table and draw the lines using pgfplotstable, that shouldn't be too hard. – ThomasH Feb 24 at 11:24