# How can I mark a x-coordinate?

I made a little plot for the birthday paradox. It looks like this:

This is perfectly fine, but I would like to mark x=23. So my question is:

How do I get the following lime line?

This is the current source:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning, calc}

\begin{document}
\begin{preview}
\begin{tikzpicture}
\begin{axis}[
width=15cm, height=8cm, % size of the image
grid = major,
grid style={dashed, gray!30},
%xmode=log,log basis x=10,
%ymode=log,log basis y=10,
xmin=0,
xmax=62,
ymin=0,
ymax=1.1,
/pgfplots/xtick={0,5,...,60},
extra y ticks={0.507297},
ylabel=probability of at least one birthday-collision,
xlabel=people,
tick align=outside]
\addplot table [id=exp]{data.csv};
\addplot[domain=0:23, blue, dashed, thick] {0.507297};
%stirling-formulae
\addplot[domain=0:60, red, thick] {1-(365/(365-x))^(365.5-x)*e^(-x)};
\end{axis}
\end{tikzpicture}
\end{preview}
\end{document}

-

## 1 Answer

You can access the plot axis coordinate system with (axis cs: xcoord,ycoord) syntax. The rest is TikZ basics.

\documentclass{standalone}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning, calc}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
width=15cm, height=8cm, % size of the image
grid = major,
grid style={dashed, gray!30},
%xmode=log,log basis x=10,
%ymode=log,log basis y=10,
xmin=0,
xmax=62,
ymin=0,
ymax=1.1,
/pgfplots/xtick={0,5,...,60},
extra y ticks={0.507297},
ylabel=probability of at least one birthday-collision,
xlabel=people,
tick align=outside]
%\addplot table [id=exp]{data.csv};
%stirling-formulae
\addplot[domain=0:60, red, thick] {1-(365/(365-x))^(365.5-x)*e^(-x)};
\coordinate (a) at (axis cs:23,0.507297);
\draw[blue,dashed](a -| current plot begin) -- (a);
\draw[lime,thick](a |- current plot begin) -- (a);
\end{axis}
\end{tikzpicture}

\end{document}


-
Is the small "bump" at x=15 correct? – Jellby Jul 23 '12 at 11:25
@Jellby I think it's just numerical noise. Add samples=500 option to the addplot and it would be more apparent. fpu library would be more suitable for these numbers that are close to zero. – percusse Jul 23 '12 at 11:31