Pgfplots - 标记区域

Pgfplots - 标记区域

我正在尝试绘制图表,以标出所有由不同曲线划分的区域中不同稳定/不稳定区域。

如何在图表的不同部分手动输入罗马数字或字母?

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{intersections}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ticks=none,
        xtick={-10,-9,...,10},   
        xmin=-2,
        xmax=2,
        xlabel={$\alpha$},
        axis x line=middle,
        ytick={-10,-9,...,10},
        ymin=0,
        ymax=10,
        ylabel={$s$},
        axis y line=middle,
        no markers,
        samples=100,
        domain=-10:10,
        restrict y to domain=-20:20,
        width = 6in ]
    \addplot[green,samples=400] (x,{-1/x});
    \addplot[blue,samples=400, domain=-1:1] (x,{1/(1+2*x)});
   \addplot[red,samples=400, domain=-1:1] (x,{-4*x/(1+x)^2}) node[pos=0.5, pin=-135:{$\frac{-4\alpha}{(1+\alpha^2)}$}] {};
%       \end{axis}
    \draw[cyan] (axis cs:1,0) -- (axis cs: 1,10) node[pos=1, pin = -30: {\tiny $\alpha=1$}] {};
    \draw[cyan] (axis cs:-1,0) -- (axis cs: -1,10) node[pos=1, pin = -120: {\tiny $\alpha=-1$}] {};
    \draw [draw=black, fill=white, thin] (axis cs: -0.5, 8) circle (1.0pt);
\end{axis} 
\end{tikzpicture}
\end{document}

答案1

鉴于您的代码,并且除了您所知道的之外,我还尝试了几个示例来给出如何给出标签的理想。

  1. 您可能需要调整轴 cs x,y 以满足您的需要。
  2. 您可以定义任意多种其他风格来满足您的需要。

在此处输入图片描述

代码:

\begin{tikzpicture}
\tikzset{                                         % for optional style
every pin/.style={fill=yellow, circle, scale=1, pin distance=10pt, inner sep=0pt,  font=\footnotesize},
small dot/.style={fill=black, circle, scale=0.3}} % user defined coordinate
\begin{axis}[ticks=none,
        xtick={-10,-9,...,10},   
        xmin=-2,
        xmax=2,
        xlabel={$\alpha$},
        axis x line=middle,
        ytick={-10,-9,...,10},
        ymin=0,
        ymax=10,
        ylabel={$s$},
        axis y line=middle,
        no markers,
        samples=100,
        domain=-10:10,
        restrict y to domain=-20:20,
        width = 6in ]
    \addplot[green,samples=400] (x,{-1/x});
    \addplot[blue,samples=400, domain=-1:1] (x,{1/(1+2*x)});
    \addplot[red,samples=400, domain=-1:1] (x,{-4*x/(1+x)^2})   node[pos=0.5, pin=-135:{$\frac{-4\alpha}{(1+\alpha^2)}$}] {};
\draw[draw=black, fill=white, thin] (axis cs: -0.5, 8) circle (1.0pt);

% ---These are examples to show how ----------------
\node[small dot, pin=above:here1] at (axis cs: 0.5,3){};
\node[small dot, label=left:here2] at (axis cs: -1,4){};
\node[small dot, label={[red]left:here3}] at (axis cs: -1.5,5){};
\node[coordinate, pin =above:{\tiny $\alpha=1$}] at (axis cs: 1,1){};
\node[coordinate, pin =above:{\tiny $\alpha=-1$}] at (axis cs: -1,1) {};
\end{axis} 
\end{tikzpicture}

相关内容