使用 pgfplot 绘制角度

使用 pgfplot 绘制角度

我想在曲线和特定轴(比如 x 轴)之间放置一个角度。我尝试了几个选项,但最终还是选择使用,angles但它仍然不起作用。

有人能帮我找出问题吗?

脚本 :

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{angles, arrows.meta,
                quotes}
\usepackage{siunitx}

\begin{center} 
\begin{tikzpicture}[scale=1,
the_angle/.style args = {#1/#2}{draw,<->,
                               angle radius=#1,
                               angle eccentricity=#2,
                               %anchor=south west,
                               }, % angle label position
dot/.style = {circle, fill, inner sep=-1.2pt}
]
\pgfplotsset{ticks=none}
  \begin{axis}[axis lines=middle,xmin=0,xmax=15,ymin=0,ymax=7, ultra thick,
    xlabel=$\scriptstyle \log(t)$,
    ylabel=$\scriptstyle \log(R)$,
    x label style={at={(1,-0.01)},anchor=north},
        y label style={at={(-0.15,1)},anchor=west},
        ]
       %
        \addplot+[no marks,blue,domain=0:8,samples=300, thick] {(1/3)*x} coordinate (A);
        \coordinate (O) at (0,0); % intersection with coordinate axis
        \coordinate (C) at (2,0);
        \pic [the_angle=9mm/1.2, $\qty{30}{\degree}$] {angle = C--O--A};
        \addplot+[no marks,dashed,blue,domain=8:14,samples=300, thin] {(1/3)*(x-8)+8/3};
        \addplot+[no marks,ForestGreen,domain=8:14,samples=300, thick] {(1/2)*(x-8)+8/3};
        \addplot+[no marks,dashed,ForestGreen,domain=0:8,samples=300, thin] {(1/2)*(x-8)+8/3};
%
    \node[dot, label=left:$\lambda_{E-G}$] at (0,8/3) {};
        \draw[gray, thick, dash pattern=on 6pt off 3pt] (0,8/3) -- (8,8/3);
  \end{axis}
\end{tikzpicture}
\end{center}

\end{document}

这篇文章中建议了这个选项:这里

我收到以下错误:

在此处输入图片描述

感谢您的帮助,

真挚地。

答案1

你错过了以下" "分数:

\documentclass[margin=3mm,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{angles, arrows.meta,
                quotes}
\usepackage{siunitx}

\begin{document}
\begin{tikzpicture}[scale=1,
the_angle/.style args = {#1/#2}{draw,<->,
                               angle radius=#1,
                               angle eccentricity=#2,
                               %anchor=south west,
                               }, % angle label position
dot/.style = {circle, fill, inner sep=-1.2pt}
]
\pgfplotsset{ticks=none}
  \begin{axis}[axis lines=middle,xmin=0,xmax=15,ymin=0,ymax=7, ultra thick,
    xlabel=$\scriptstyle \log(t)$,
    ylabel=$\scriptstyle \log(R)$,
    xlabel style={at={(1,-0.01)},anchor=north},
        ylabel style={at={(-0.15,1)},anchor=west},
        ]
       %
        \addplot+[no marks,blue,domain=0:8,samples=300, thick] {(1/3)*x} coordinate (A);
        \coordinate (O) at (0,0); % intersection with coordinate axis
        \coordinate (C) at (2,0);
        \addplot+[no marks,dashed,blue,domain=8:14,samples=300, thin] {(1/3)*(x-8)+8/3};
        \addplot+[no marks,green,domain=8:14,samples=300, thick] {(1/2)*(x-8)+8/3};
        \addplot+[no marks,dashed,green,domain=0:8,samples=300, thin] {(1/2)*(x-8)+8/3};

        \draw[gray, thick, dash pattern=on 6pt off 3pt] (0,8/3) -- (8,8/3);
  \end{axis}
      \pic [the_angle=9mm/1.2, "\qty{30}{\degree}"] {angle = C--O--A};
      \node[dot, label=left:$\lambda_{E-G}$] at (0,8/3) {};
\end{tikzpicture}

\end{document}

相关内容