pgfplot 中的剪辑和标签问题

pgfplot 中的剪辑和标签问题

我想在轴的原点添加零。我尝试了clip = false和,\node[anchor=east] (zero) at (axis cs:0,0) {0};但结果很糟糕。这是我的图表:

\documentclass[tikz]{standalone}
\definecolor{viola}{HTML}{8100FF}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\renewcommand{\dim}[1]{\left[\mathrm{#1}\right]}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
  \begin{axis}[
  legend pos=outer north east,
  legend cell align={left},
  xmax=8,xmin=0,
  ymax=1,ymin=0,
  yticklabels=\empty, xticklabels=\empty,
  width=8cm,
  height=6cm,
  xtick=\empty, ytick={0},
    axis lines=middle,
    x label style={at={(1,0)},right},
    y label style={at={(0,1)},above},
    xlabel={$T$}, ylabel={$\xi$},
    restrict y to domain=-10:1
               ]
        \node[anchor=east] (zero) at (axis cs:0,0) {0};                 
        \addplot [viola,smooth,domain=0:7,samples=1000] 
        {1-( (0*exp(-1/4)) *exp(1/x))};
        \addlegendentry{$r = 0$};
        \addplot [blue, domain=0:7, samples=100,  smooth]
        {1-( (0.2*exp(-1/4)) *exp(1/x))};
        \addplot [green, domain=0:7, samples=100,  smooth] 
        {1-( (0.4*exp(-1/4)) *exp(1/x))};
        \addplot [yellow,smooth,domain=0:7] 
        {1-( (0.6*exp(-1/4)) *exp(1/x))};
        \addplot [orange,smooth,domain=0:7] 
        {1-( (0.8*exp(-1/4)) *exp(1/x))};
        \addplot [red,smooth,domain=0:7] 
        {1-( (1*exp(-1/4)) *exp(1/x))};
        
        \addplot[only marks, mark=*,fill=cyan] coordinates { 
        (0.5377969296,0) 
        (0.8574191432,0)
        (1.3143616208,0)
        (2.1135234692,0)  
        (4,0)   
        };
    \end{axis}
    \draw[-stealth] (6,3) -- ++(0,-2) node[midway,above,anchor=west] {$r$ crescente};
\end{tikzpicture}
\end{figure}
\end{document}

有任何想法吗?

答案1

使用时axis lines=middle,PGFPlots 将隐藏原点周围的刻度标签,以防止轴线干扰它们。要禁用此功能,您可以hide obscured y ticks=false这样使用:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=8,
ymin=0, ymax=1,
xtick=\empty, ytick={0},
axis lines=middle,
hide obscured y ticks=false,
]
\end{axis}
\end{tikzpicture}
\end{document}

带有“0”标记的空图表

相关内容