pgfplots:更改 addplot 中節點標籤的垂直位置

pgfplots:更改 addplot 中節點標籤的垂直位置

在下面的 MWE 中,如何更改label與曲線關聯的垂直位置?例如,如果我想把它放在曲線下方?

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}

\begin{document}

    \begin{tikzpicture}
    \begin{axis} []

    \addplot[
        domain=10:400,
        samples=100,
    ] { sqrt(x)}
    node[pos=0.97,label={$f(x)$}] {}
    ;

    \end{axis}
    \end{tikzpicture}

\end{document}  

在此輸入影像描述

答案1

您可以label=below:{$f(x)$}照常使用。所有位置說明符(例如rightleft below left)都可以使用。另外,由於label是節點,您也可以將其他選項傳遞給它,例如

label={[text=red]below:{$f(x)$}}

代碼:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}

\begin{document}

    \begin{tikzpicture}
    \begin{axis} []

    \addplot[
        domain=10:400,
        samples=100,
    ] { sqrt(x)}
    node[pos=0.97,label=below:{$f(x)$}] {}
    ;

    \end{axis}
    \end{tikzpicture}

\end{document}

在此輸入影像描述

相關內容