Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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:

Ideal plot

What is the best way to show events in this kind of plots? How to do it with GnuPlot and PgfPlots?

share|improve this question
I can't help with latex or gnuplot, but if an Excel solution is acceptable, something like this is very easy. – David Vandenbos 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

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.