我试图在流形上绘制两个矢量场 (x,y) 和 (-y,x),其中范数由 $x^2 - y^2$ 而不是 $x^2 + y^2$ 给出。此外,我希望仅当 x>y 时才绘制矢量场。以下是我的尝试:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\def\rescale{
0.5*(sign(x^2-y^2)+1)*sqrt(x^2-y^2)/sqrt(x^2+y^2)
}
\begin{tikzpicture}
\begin{axis}[
xmin = 0, ymax = 5,
ymin = -5, ymax = 5,
view={0}{90}
]
\draw [black] (0,0) -- (5,5);
\draw [black] (0,0) -- (5,-5);
\clip (0.0, 0) -- (4.80, 4.80) -- (4.80, -4.80) -- cycle;
\addplot3[blue, quiver={u={x*\rescale}, v={y*\rescale}, scale arrows=0.15}, -stealth,samples=20] {0};
\addplot3[red, quiver={u={y*\rescale}, v={x*\rescale}, scale arrows=0.15}, -stealth,samples=20] {0};
\end{axis}
\end{tikzpicture}
\end{document}
黑色三角线附近的矢量箭头实际上是从所需区域外部绘制的矢量!