# Show events on a trend plot

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?

-
I can't help with latex or gnuplot, but if an Excel solution is acceptable, something like this is very easy. –  dav Jul 16 '12 at 21:01
@David Thanks but I would like to use the same framework for all my graphs. Moreover I do not have an Excel copy. –  Claudio Jul 17 '12 at 7:32
Where is the information coming from that Event A has happened at such and such an x value? 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