2

I am trying to plot a couple of chi-squared cdfs and I'd like to draw a vertical line intersecting with then it hits a certain value, e.g. 0.005.

Given I know the y value how can I find the intersecting x value?

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=newest}

\begin{filecontents}{data.csv} 0,0,0 0.05005,0.17702,0.00037825 0.1001,0.24829,0.00058426 0.15015,0.30161,0.00077812 0.2002,0.34544,0.00097319 0.25025,0.3831,0.0011743 0.3003,0.41631,0.001384 0.35035,0.44609,0.0016036 0.4004,0.47312,0.0018341 0.45045,0.49788,0.0020762 0.5005,0.52072,0.0023304 0.55055,0.54191,0.0025973 0.6006,0.56165,0.0028771 0.65065,0.58012,0.0031702 0.7007,0.59745,0.003477 0.75075,0.61376,0.0037977 0.8008,0.62915,0.0041325 0.85085,0.64369,0.0044819 0.9009,0.65746,0.0048459 0.95095,0.67052,0.0052249 1.001,0.68293,0.005619 \end{filecontents}

\begin{document}

\begin{figure}
\centering

\begin{tikzpicture} \begin{axis}[ xmin=0, xmax=50, ymin=0, ymax=1, grid=both, minor tick num = 1, major grid style = {lightgray}, minor grid style = {lightgray!25}, width=0.75\linewidth, xlabel={$x$}, ylabel={$\text{cdf}(x)$}, legend pos=south east,]

    \pgfplotstableread[col sep=comma]{data.csv}\data

    \addplot[smooth, very thick, blue]  table[x index = {0}, y index = {1}] {\data};
    \addplot[smooth, very thick, red]   table[x index = {0}, y index = {2}] {\data};

    \legend{$\mathcal{H}_{0}$, $\mathcal{H}_{1}$};
\end{axis}

\end{tikzpicture} \end{figure}

\end{document}

Torbjørn T.
  • 206,688

0 Answers0