我正在尝试让箭筒图与网格完美配合。我希望箭头居中(箭头的中点位于每个单元格的中心,或者箭头的起点位于单元格的中心。
\documentclass{standalone}
\usepackage{pgfplots,}
\pgfplotsset{compat=1.8}
\usepackage{amsmath}
\begin{document}
\def\length{sqrt((2.*x^2-2.2-2.*y^2)^2 + (4.*x^2*y)^2 )}
\begin{tikzpicture}[enter image description here][1]
\begin{axis}[ enlargelimits = false ,
view={0}{90},
domain=-2:2,
axis equal image
]
\addplot3 [gray,quiver={u={(2.*x^2-2.2-2.*y^2)/\length}, v={4.*x^2*y/\length}, scale arrows=0.2}, -stealth,samples=12] {0};
\end{axis}
\begin{scope}%[xshift=4pt,yshift=4pt]
\draw[step=3.99mm, blue] (0,0) grid (5.5,5.5);
\end{scope}
\end{tikzpicture}
\end{document}
我不确定“每个箭头”选项是否可行。以下是我目前所得到的
答案1
像这样吗?
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{amsmath}
\begin{document}
\def\length{sqrt((2.*x^2-2.2-2.*y^2)^2 + (4.*x^2*y)^2 )}
\begin{tikzpicture}
\begin{axis}[ enlargelimits = false ,
view={0}{90},
domain=-2:2,
minor x tick num=2,
minor y tick num=2,
axis equal image, grid=both,
minor grid style={blue,very thin},
axis equal image
]
\addplot3[white,quiver={u={(2.*x^2-2.2-2.*y^2)/\length}, v={4.*x^2*y/\length}, scale arrows=0.2}, -stealth,samples=12] {0};
\addplot3[domain=-11/6:11/6,gray,quiver={u={(2.*x^2-2.2-2.*y^2)/\length}, v={4.*x^2*y/\length}, scale arrows=0.2}, -stealth,samples=12] {0};
\end{axis}
\end{tikzpicture}
\end{document}
解释:除了每行有 13 个方框,每个方框有 12 支箭之外,pgfplots
似乎真的将箭移到了边界。在这个提议中,我将箭的范围缩小了 1/12。