以下绘图的单个标签与曲线相交。我怎样才能使它离轴稍远一点并用虚线指向轴?
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
minor tick num=1,
axis x line=middle,
axis y line=left,
yticklabels={,},
xticklabels={$s$},
xtick=1,
ytick=\empty,
]
\addplot[blue,domain=0:20] {((x)/(x+1))-0.5};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以append after command
在xticklabel style
选项中使用插入绘图命令:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,
axis y line=left,
tickwidth=0pt,
xticklabels={$s$},
xticklabel style={
yshift=-3ex,
name=label,
append after command={(label.north) edge [densely dashed] ++(0,3ex)}},
xtick=1,
ytick=\empty,
]
\addplot[blue,domain=0:20, smooth] {((x)/(x+1))-0.5};
\end{axis}
\end{tikzpicture}
\end{document}