\begin{tikzpicture}
\begin{axis}[
xtick = data,
ylabel=Size of Slick,
legend style={at={(0.5,-0.13)},
anchor=north,legend columns=-1},
ybar interval=1,]
\addplot
coordinates {(1, 1.047) (2, 2.005) (3, 3.348) (4, 5.719) (5, 7.273) (6, 8.41) (7, 9.117)};
\addplot
coordinates {(1, 1.139) (2, 2.087) (3, 3.413) (4, 5.765) (5, 7.304) (6, 8.426) (7, 9.127)};
\legend{Initial Observation, 10 min. later}
\end{axis}
\end{tikzpicture}
因此,这给了我一个没有数据点的图x=7
。我还想知道如何去掉顶部和右侧那些难看的勾号。谢谢!
答案1
您可能只想要ybar
(而不是ybar interval
)并xtick pos=lower,ytick pos=left
删除顶部和右侧的勾号。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick = data,
ylabel=Size of Slick,
legend style={at={(0.5,-0.13)},
anchor=north,legend columns=-1},
ybar,bar width=1em,xtick pos=lower,ytick pos=left]
\addplot
coordinates {(1, 1.047) (2, 2.005) (3, 3.348) (4, 5.719) (5, 7.273) (6, 8.41) (7, 9.117)};
\addplot
coordinates {(1, 1.139) (2, 2.087) (3, 3.413) (4, 5.765) (5, 7.304) (6, 8.426) (7, 9.127)};
\legend{Initial Observation, 10 min.\ later}
\end{axis}
\end{tikzpicture}
\end{document}