Quiver plot in polar coordinates

I need to plot an analytically given vector field in polar coordinates. I would like to get something like the picture in this answer by Christian Feuersänger, but in circular axes. I tried to use the polaraxis environment plus the addplot3 command of the pgfplots package to achieve this, but I wasn't succeeded to understand how does the quiver option work in this context. Could you please help me?

• just to clarify; by the answer at the bottom, do you mean the answer by Christian Feuersänger? Please edit this in your question, as it is not certain that that answer will be at the bottom in the future. Also, could you add an MWE? Jun 28 '16 at 17:31

In polar coordinates, like in cartesian coordinates, the components given in u and v are added to the coordinate of the point.

So if you plot u=10, v=0, you get arrows that end 10° clockwise from where they start, at the same distance from the centre as the starting point:

If you plot u=0, v=0.1, you get arrows pointing outward from the centre (because the angles of the starting and end points are the same):

If you want the arrows to start on a cartesian grid, set data cs=cart:

If you want to draw the same quiver (in terms of cartesian coordinates) at every point, you need to find the appropriate offset in terms of angle and radius. You can do that using

    quiver={
% Draw constant quivers (0.1, 0.2)
% Angle of vector pointing to quiver end minus angle of vector pointing to quiver start
u={atan2( y+0.2, x+0.1)) - atan2(y,x) },
% Length of vector pointing to quiver end minus length of vector pointing to quiver start
v={veclen(y+0.2, x+0.1) - veclen(y,x) }
}


\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}
samples=13,
samples y=10,
quiver={
u={10},
v={0.1},
},
-latex,
domain=0:360,
domain y=0:1] {0};
\end{polaraxis}
\end{tikzpicture}
\end{document}


Arrows on cartesian grid:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[ymax=1]
samples=15,
samples y=15,
quiver={
u={10},
v={-0.1},
},
-latex,
domain=-1:1,
domain y=-1:1,
data cs=cart
] (x, y, 0);
\end{polaraxis}
\end{tikzpicture}
\end{document}


\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[ymax=1,]
samples=9,
samples y=9,
quiver={
% Draw constant quivers (0.1, 0.2)
% Angle of vector pointing to quiver end minus angle of vector pointing to quiver start
u={atan2( y+0.2, x+0.1)) - atan2(y,x) },
% Length of vector pointing to quiver end minus length of vector pointing to quiver start
v={veclen(y+0.2, x+0.1) - veclen(y,x) }
},
-latex,
domain=-1:1,
domain y=-1:1,
data cs=cart
] (x, y, 0);
\end{polaraxis}
\end{tikzpicture}
\end{document}


Constant quivers

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[ymax=1,]
samples=9,
samples y=9,
quiver={
% Draw constant quivers (0.1, 0.2)
% Angle of vector pointing to quiver end minus angle of vector pointing to quiver start
u={atan2( y+0.2, x+0.1)) - atan2(y,x) },
% Length of vector pointing to quiver end minus length of vector pointing to quiver start
v={veclen(y+0.2, x+0.1) - veclen(y,x) }
},
-latex,
domain=-1:1,
domain y=-1:1,
data cs=cart
] (x, y, 0);
\end{polaraxis}
\end{tikzpicture}
\end{document}

• But is it possible in principle to put these arrows at nodes of a uniform cartesian grid? The vector field looks sparse at big radii wheneas it is very concentrated near zero Jun 29 '16 at 7:17
• @Nimza: Sure, that's possible, simply set data cs=cart. It would be good if you could edit your question to provide an example of the kind of plot you're trying to produce.
– Jake
Jun 29 '16 at 7:24
• By the way, do you know whether it is possible to specify the absolute values of $u$ and $v$ inside of the quiver? These "relative" coordinates inside of the quiver seem very difficult to work with. For example, is there a simple way to draw a constant vector field? (the same quiver at any point) Jul 9 '16 at 13:12
• @Nimza: I've edited my answer. Again, it would be great if you could make your question a bit more specific. It seems like you have a particular application in mind, but we don't know what it is.
– Jake
Jul 10 '16 at 12:49