\documentclass{article} \usepackage{pgfplots} \usepackage{tikz} \begin{document}
\begin{tikzpicture} \begin{axis}[
xmin=-4.5, xmax=4.5,
ymin=-1.5, ymax=1.5,
axis lines=middle,
axis equal,
xlabel=$\operatorname{Re}(w)$,
ylabel=$\operatorname{Im}(w)$,
xtick={-4,-3,...,4},
ytick={-1,-0.5,...,1},
restrict y to domain=-1.5:1.5,
restrict x to domain=-4.5:4.5,
samples=200 ] \addplot[gray,smooth,domain=-4.5:4.5] ({x},{tan(deg(x))}); \addplot[gray,smooth,domain=-4.5:4.5] ({x},{tan(deg(x))+2*pi}); \addplot[gray,smooth,domain=-4.5:4.5] ({x},{tan(deg(x))-2*pi}); \addplot[gray,smooth,domain=-4.5:4.5] ({x},{tan(deg(x))});
\addplot[black,dashed] coordinates {(0,-1.5) (0,1.5)}; \addplot[black,dashed] coordinates {(-4.5,0) (4.5,0)};
\node[below left] at (0,0) {0}; \node[below] at (4.5,0) {$\pi$}; \node[above] at (-4.5,0) {$-\pi$}; \node[left] at (0,1.5) {$\frac{\pi}{2}$}; \node[left] at (0,-1.5) {$-\frac{\pi}{2}$};
\filldraw[fill=gray!30, draw=black, thick] (-4.5,-1.5) -- (-4.5,-0.5) -- plot[domain=-4.5:4.5,smooth] ({x},{tan(deg(x))}) -- (4.5,1.5) -- (4.5,0.5) -- plot[domain=4.5:-4.5,smooth] ({x},{tan(deg(x))-2*pi}) -- cycle; \filldraw[fill=gray!30, draw=black, thick] plot[domain=-4.5:4.5,smooth] ({x},{tan(deg(x))+2*pi}) -- (4.5,-0.5) -- (4.5,-1.5) -- plot[domain=4.5:-4.5,smooth] ({x},{tan(deg(x))}) -- cycle;
\node[above right] at (-2.5,0.7) {$\mathcal{R}_1$}; \node[above right] at (-1.5,1.2) {$\mathcal{R}_2$}; \node[above right] at (1.5,1.2) {$\mathcal{R}_3$}; \node[above right] at (2.5,0.7) {$\mathcal{R}_4$}; \node[below left] at (-2.5,-0.7) {$\mathcal{R}_5$}; \node[below left] at (-1.5,-1.2) {$\mathcal{R}_6$}; \node[below left] at (1.5,-1.2) {$\mathcal{R}_7$}; \node[below left] at (2.5,-0.7) {$\mathcal{R}_8$}; \end{axis} \end{tikzpicture}
\end{document}
我有一段代码,用来绘制函数 \tan(z) 如何映射的图表,就像 Bruce Palka 在《复杂函数理论导论》一书中第 79-80-81 页的练习 3.7 中那样,但是它会产生错误,有人可以帮我纠正吗?