![pgf 图中的条形图 — 缺少数据并删除刻度?](https://linux22.com/image/407670/pgf%20%E5%9B%BE%E4%B8%AD%E7%9A%84%E6%9D%A1%E5%BD%A2%E5%9B%BE%20%E2%80%94%20%E7%BC%BA%E5%B0%91%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%88%A0%E9%99%A4%E5%88%BB%E5%BA%A6%EF%BC%9F.png)
\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}