如何繪製這一圖

如何繪製這一圖
\begin{tikzpicture}
\begin{axis}[
    axis lines=middle,
    xmin=-5, xmax=5,
    ymin=-5, ymax=5,
    xlabel=$x$, ylabel=$y$,
    domain=-10:10, samples=200,
    restrict y to domain=-10:10,
    enlargelimits={abs=1cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={-2,1}, ytick={1},
    yticklabels={1},
    xticklabels={-2,1},
    xlabel style={below right},
    ylabel style={above left},
    xlabel={$x$},
    ylabel={$y$},
    axis line style={->},
]

\addplot[red, thick, domain=-10:-2] {(x-1)/(x+2)};
\addplot[red, thick, domain=-2:10] {(x-1)/(x+2)};
\draw[dashed] ({rel axis cs:0,0} -| {axis cs:-2,0}) -- ({rel axis cs:0,1} -| {axis cs:-2,0});
\draw[dashed] ({rel axis cs:1,0} |- {axis cs:0,1}) -- ({rel axis cs:0,1} -| {axis cs:1,0});

\end{axis}
\end{tikzpicture}

相關內容