我如何在这条数轴的两端添加箭头?
\begin{tikzpicture}
\begin{axis}[
axis y line=none,
axis lines=left,
axis line style={-},
xmin=112.5,
xmax=121.5,
ymin=0,
ymax=1,
xlabel=$\mu$,
scatter/classes={o={mark=*}},
restrict y to domain=0:1,
xtick={113,114,...,121}
]
\end{axis}
\end{tikzpicture}
答案1
您需要做的就是更改axis line style
:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis y line=none,
axis lines=left,
axis line style={<->},
xmin=112.5,
xmax=121.5,
ymin=0,
ymax=1,
xlabel=$\mu$,
scatter/classes={o={mark=*}},
restrict y to domain=0:1,
xtick={113,114,...,121}
]
\end{axis}
\end{tikzpicture}
\end{document}
正如 @azetina 所说,您还可以stealth
通过执行以下操作来使用axis line style={stealth-stealth},
,这可能更具美感: