如何去除此图中每条柱状图两侧的垂直线?我认为它们的出现是由于ybar interval
我需要该命令xticklabel
。
\documentclass[margin=1cm]{standalone}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents}{foo.csv}
n,o
46,7
89,10
96,35
100,66
32,60
8,10
43,136
44,154
90,115
88,161
10,145
7,82
8,96
31,88
9,51
6,177
38,174
50,52
32,14
44,50
17,187
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar interval,
xticklabel=\rotatebox{90}{\pgfmathprintnumber\tick--\pgfmathprintnumber\nexttick},
xtick style={draw=none},
ymin=0
]
\addplot+ [hist={data=x}] table [x=o,col sep=comma] {foo.csv};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
只需添加grid=none
到axis
选项中即可。
% used PGFPlots v1.15
\begin{filecontents}{foo.csv}
n,o
46,7
89,10
96,35
100,66
32,60
8,10
43,136
44,154
90,115
88,161
10,145
7,82
8,96
31,88
9,51
6,177
38,174
50,52
32,14
44,50
17,187
\end{filecontents}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar interval,
xticklabel=\pgfmathprintnumber\tick--\pgfmathprintnumber\nexttick,
xticklabel style={
rotate=90,
},
xtick style={draw=none},
ymin=0,
grid=none, % <-- added
]
\addplot+ [hist={data=x}] table [x=o,col sep=comma] {foo.csv};
\end{axis}
\end{tikzpicture}
\end{document}