答案1
这是另一种解决方案PGFPlots解析报价(来自这我使用 Jake 的回答 (https://www.javaji.org/doc/api/javase/1.0/docs ...
代码
\documentclass[border=10pt]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{pgfplots}
\usepackage{amsmath}
\makeatletter
\pgfplotsset{
ytick parsed/.code={
\c@pgf@counta 0\relax
\foreach \y in {#1} {
\pgfmathparse{\y}
\ifnum\c@pgf@counta=0
\xdef\pgfplots@ytick{\pgfmathresult}
\else
\xdef\pgfplots@ytick{\pgfplots@ytick,\pgfmathresult}
\fi
\global\advance\c@pgf@counta 1\relax
}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}[font=\tiny]
\pgfmathsetmacro{\re}{2}
\pgfmathsetmacro{\im}{2*sqrt(5)}
\pgfmathsetmacro{\n}{sqrt(\re^2 + \im^2)}
\begin{axis}[axis equal,
xlabel=$\Re(z)$,
ylabel=$\Im(z)$,
axis lines=middle,
grid=major,
grid style=dashed,
xmin=-6,xmax=6,
xtick={-6,...,6},
ymin=-6,ymax=6,
ytick parsed={-2*sqrt(5), -sqrt(5), sqrt(5), 2*sqrt(5)},
yticklabels={$-2\sqrt{5}$, $-\sqrt{5}$, $\sqrt{5}$, $2\sqrt{5}$}]
\addplot[very thick, MediumPurple!50, domain=0:360, samples=100, variable=\t] ({\n*cos(t)},{\n*sin(t)});
\draw[|-|, MediumOrchid, very thick] (axis cs:0,0) -- node[left,black] {\small n} (axis cs:\re,\im);
\end{axis}
\end{tikzpicture}
\end{document}
结果
答案2
我建议使用pgfplots
,因为它可以轻松绘制坐标轴和网格。还有一个unit vector ratio
纵横比选项(“倾斜?”)。我不知道是否可以在那里添加 5 的平方根作为公式。在其他地方,5^0.5
似乎有效,但sqrt(5)
在大多数地方似乎也有效。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
unit vector ratio={1 2.236068},
xmin=-4.5,xmax=4.5,
ymin=-2.5,ymax=2.5,
xtick={-4,...,4},
yticklabel={$\pgfmathprintnumber{\tick}\cdot\sqrt{-5}$},
axis x line=middle,
axis y line=middle,
grid=both,
major grid style={dashed}
]
\draw[lightgray] (axis cs:0,0) circle [x radius={(5)^0.5*1.3},y radius=1.3];
\draw[purple,|-|] (0,0) -- node[left] {$n$} ({1.3*(5/2)^0.5},{1.3*1/(2^0.5)});
\end{axis}
\end{tikzpicture}
\end{document}