
다음 CSV 파일이 있습니다.
1,36
2,22
3,13
4,8
5,7
6,2
7,1
8,7
9,12
10,5
11,6
12,2
13,7
14,4
15,4
16,1
17,2
18,1
19,1
20,2
21,2
22,1
23,1
24,1
25,1
26,1
27,2
28,0
29,0
30,0
31,0
32,1
33,0
34,0
35,0
36,1
누구의 이름은 입니다 file
.
다음 코드
\begin{tikzpicture}
\begin{axis}[black,ylabel=Frequency, legend pos=outer north east]
\addplot table[col sep=comma] {file.csv};
\end{axis}
\end{tikzpicture}
괜찮습니다만 대신에 조각별 상수 그래프를 그리고 싶습니다. 예를 들어 를 보면 file
,
1,36
은 1과 2 사이의 일정한 선에 해당하며, 일정한 세로 좌표는 36입니다.
2,22
2와 3 사이의 일정한 선에 해당하며 일정한 세로 좌표는 22 등입니다.
답변1
(여기서 내 의견을 전체 답변으로 확장합니다.)
const plot
에 대한 옵션을 사용할 수 있습니다 \addplot
.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{filecontents*}{file.csv}
1,36
2,22
3,13
4,8
5,7
6,2
7,1
8,7
9,12
10,5
11,6
12,2
13,7
14,4
15,4
16,1
17,2
18,1
19,1
20,2
21,2
22,1
23,1
24,1
25,1
26,1
27,2
28,0
29,0
30,0
31,0
32,1
33,0
34,0
35,0
36,1
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ylabel=Frequency]
\addplot+[const plot] table[col sep=comma] {file.csv};
\end{axis}
\end{tikzpicture}
\end{document}