점선으로 그래프의 점 연결하기

점선으로 그래프의 점 연결하기

이 점들을 수직 점선으로 어떻게 연결할 수 있습니까?

\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

이와 같이?

\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}

여기에 이미지 설명을 입력하세요

그래프와 함께 좌표를 정의하고 선을 그리는 것이 형식적인 일이 됩니다.

관련 정보