我正在使用 pgfplots 绘制 a 函数。我在论坛上四处寻找,但找不到解决方案。我希望原点在 x 轴上显示为 0。我还想让轴标签分别出现在轴的左侧和下方。有什么想法吗?
我有以下情节:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=7cm, height=2cm,xmin=-6,xmax=6,ymin=0,ymax=1,
no markers,
samples=50,
axis lines=left,
axis lines=middle,
scale only axis,
% extra y ticks={0.5},
/pgfplots/ytick={0, 0.5,1}, % make steps of length 0.5
/pgfplots/xtick={-5,0,5}, % make steps of length 5
xlabel=$Li$,
ylabel={$f_{comp}(Li))$}
]
\addplot {1/(1+exp(-x)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
middle
轴线选项假定轴线相交,因此不0
显示刻度。如果使用axis y line=middle, axis x line=bottom
而不是axis lines=middle
,则可以得到所需的刻度标记:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=7cm, height=2cm,xmin=-6,xmax=6,ymin=0,ymax=1,
no markers,
samples=50,
axis y line=middle,
axis x line=bottom,
scale only axis,
ytick={0, 0.5,1}, % make steps of length 0.5
xtick={-5,0,5}, % make steps of length 5
xlabel=$Li$,
ylabel={$f_{comp}(Li))$}
]
\addplot {1/(1+exp(-x)};
\end{axis}
\end{tikzpicture}
\end{document}