1

How could I connect these points with dotted, vertical lines?

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[axis lines=center]
\addplot [only marks] table{
0 0.00390625
1 0.05078125
2 0.26171875
3 0.68359375
4 1
};
\addplot [domain=0:1] {0.00390625};
\addplot [domain=1:2] {0.05078125};
\addplot [domain=2:3] {0.26171875};
\addplot [domain=3:4] {0.68359375};
\addplot [domain=4:5] {1};
\end{axis}
\end{tikzpicture}

\end{document}
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Sep 29 '14 at 3:46
1

Like this?

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[axis lines=center]
\addplot [only marks] table{
0 0.00390625
1 0.05078125
2 0.26171875
3 0.68359375
4 1
};
\addplot [domain=0:1] {0.00390625}coordinate[pos=1](b);
\addplot [domain=1:2] {0.05078125}coordinate[pos=0](c)coordinate[pos=1](d);
\addplot [domain=2:3] {0.26171875}coordinate[pos=0](e)coordinate[pos=1](f);
\addplot [domain=3:4] {0.68359375}coordinate[pos=0](g)coordinate[pos=1](h);
\addplot [domain=4:5] {1}coordinate[pos=0](i);
\draw[thick,dotted,red] (b) -- (c)(d) -- (e) (f) -- (g) (h) -- (i);
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

I have defined the coordinates along with the graph and then it becomes a formal affair to draw the lines.

  • Yes, that's exactly what I need. Thanks! How did you insert the preview of that code? – jodawill Sep 29 '14 at 4:18
  • Never mind. I see now that I can view the source of your comment by clicking edit. – jodawill Sep 29 '14 at 4:31
  • @jodawill Press Ctrl+G and upload the png figure. – user11232 Sep 29 '14 at 5:49

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.