3

I'm plotting some timing results using pgfplots. The times are shown on a log scale.

enter image description here

Each of the three techniques eventually ends in a timeout, and I'd like to show that somehow in the graph.

I think it would be nice to show each of the three lines shooting off the top of the graph somehow. For instance, Technique A times out when number of threads is 4, so I'd quite like an additional green data-point at x=4, positioned a few millimetres above the current extent of the y-axis.

Alternative suggestions for how to depict "time out" are also welcome.

\documentclass{article}

\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[xlabel=Number of threads, ylabel=Simulation time /s, legend
pos=south east]
\addplot[color=green,mark=square] coordinates {
(1, 0.006)
(2, 0.061)
(3, 25)
};
\addplot[color=blue,mark=x] coordinates {
(1, 0.006)
(2, 0.009)
(3, 0.053)
(4, 1.3)
(5, 70)
};
\addplot[color=red,mark=+] coordinates {
(1, 0.360)
(2, 0.370)
(3, 0.360)
(4, 0.462)
(5, 3.2)
(6, 120)
};
\legend{Technique A, Technique B, Technique C}
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
4

Vertical line

Time out could be interpreted as infinite value for the vertical time axis, visualized by a vertical line to make clear that the next thread is never reached.

\documentclass{article}

\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
  xlabel=Number of threads,
  ylabel=Simulation time in s,
  legend pos=south east,
  ymax=250,
]
\addplot[color=green,mark=square] coordinates {
(1, 0.006)
(2, 0.061)
(3, 25)
(3, 1000)
};
\addplot[color=blue,mark=x] coordinates {
(1, 0.006)
(2, 0.009)
(3, 0.053)
(4, 1.3)
(5, 70)
(5, 1000)
};
\addplot[color=red,mark=+] coordinates {
(1, 0.360)
(2, 0.370)
(3, 0.360)
(4, 0.462)
(5, 3.2)
(6, 120)
(6, 1000)
};
\legend{Technique A, Technique B, Technique C}
\node[above right] at (rel axis cs:0, 1) {Time out:};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

Result

Time out as data point outside

Basically this variant is similar to Torbjørn T.'s answer, which draws a connected line to the outside of the plot area.

However, I do not like the connecting line, because their slopes are smaller, destroying the curve forms.

Therefore, the example does not connect the time out points and labels the points with "Time out".

\documentclass{article}

\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
  xlabel=Number of threads,
  ylabel=Simulation time in s,
  legend pos=south east,
  xmax=7.5,
  ymax=200,
  clip=false,
]
\addplot[color=green,mark=square] coordinates {
(1, 0.006)
(2, 0.061)
(3, 25)
};
\addplot[color=blue,mark=x] coordinates {
(1, 0.006)
(2, 0.009)
(3, 0.053)
(4, 1.3)
(5, 70)
};
\addplot[color=red,mark=+] coordinates {
(1, 0.360)
(2, 0.370)
(3, 0.360)
(4, 0.462)
(5, 3.2)
(6, 120)
};
\addplot[color=green, mark=square] coordinates {(4, 320)};
\addplot[color=blue, mark=x] coordinates {(6, 320)};
\addplot[color=red, mark=+] coordinates {(7, 320)};
\legend{Technique A, Technique B, Technique C}
\node[above right] at (rel axis cs:0, 1) {Time out:};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

Result

  • the vertical line is a pretty good simple solution. when we visualize this, we typically show the curve leaving the chart in an asymptotic fashion, instead of showing the actual vertical. just another variation. – aeroNotAuto Jun 25 '15 at 2:48
2

I'm not sure if this is anything like what you had in mind, but if you add another data point, set the ymax to a smaller value than the y-value for this new data point, and finally add clip=false, you get plot lines extending out of the axis.

enter image description here

\documentclass{article}

\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
xlabel=Number of threads,
ylabel=Simulation time /s,
legend pos=south east,
ymax=200,
clip=false]
\addplot[color=green,mark=square] coordinates {
(1, 0.006)
(2, 0.061)
(3, 25)
(4,300)
};
\addplot[color=blue,mark=x] coordinates {
(1, 0.006)
(2, 0.009)
(3, 0.053)
(4, 1.3)
(5, 70)
(5.5,300)
};
\addplot[color=red,mark=+] coordinates {
(1, 0.360)
(2, 0.370)
(3, 0.360)
(4, 0.462)
(5, 3.2)
(6, 120)
(6.3,300)
};
\legend{Technique A, Technique B, Technique C}
\end{semilogyaxis}
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.