I am making a quiver plot using pgfplot and I want the arrow head size to be scaled "nicely" with the length of the vector (e.g., the way Matlab quiver plot does). I've come across several solutions to similar requests, but I can't get them to work quite right.

Currently, I'm attempting to scale the arrow line width by the vector length (using point meta data). It works nicely if I do not actually draw the arrow heads, just the arrow-less vector. However, adding the arrow heads it looks pretty silly. The size of the arrow head doesn't seem the scale proportionally with the width of the line.

Here's a MWE of my current attempts. Note I tried pasting the data in a table but it was too long to share.

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}
\begin{axis} [
xlabel=$x$,
ylabel=$y$,
xmin=-0.37, xmax=0.37,
ymin=0, ymax=0.5,
width=2.5 in,
axis equal image,
]
black,
point meta={sqrt( (\thisrowno{2})^2 + (\thisrowno{3})^2 )},
quiver={%
u=\thisrowno{2},
v=\thisrowno{3},
scale arrows=0.005,
every arrow/.append style={%
line width=0.5pt*\pgfplotspointmetatransformed/1000,
%-latex,
%-{Latex[scale length={max(0.05,\pgfplotspointmetatransformed/1000)}]}
},
},
] table {quiverData.dat};
\end{axis}
\end{tikzpicture}
\end{document}


Plotting without drawing the arrowheads (as-is in the above example) gives the following output...

If I uncomment the line -latex to draw the arrowheads, I get the following...

where, the arrowheads dwarf the vector and don't seem to be scaled quite right with the line width. (Actually, I'd prefer not to scale the line width and just scale the arrowhead width and length. I'm not sure if that's a possibility)

I also tried scaling the length of the vector to shorten the arrowhead, by uncommenting the line -{Latex[scale length={max(0.05,\pgfplotspointmetatransformed/1000)}]}. This is somewhat better, but still no good.

What I would like is something like the output of matlab's quiver, produced using the same data...

What am I missing here?

• AFAIK, there is not yet a solution for the problem that quiver-plot functionality of pgfplots is incomparable to that of matlab. I ended up writing a code to convert my quiver-data file to TikZ \draw commands. Each \draw command draws only one vector and you can scale it easily. – Hoang-Ngan Nguyen Jun 24 '16 at 6:00
• As it seems nobody is able to help you. This most probably is the case because you didn't provide and (dummy) data we can play with to find a suitable solution to your problem. Could you at least provide a reduced data file which includes at least the min and max vectors of your problem? This seems to be the case for e.g. the lower left quadrant of your provided figures. Maybe this can be reduced even more ... – Stefan Pinnow Feb 22 '17 at 0:56

This is a direct application of length=0pt 1 and width=0pt 3. See the manual page 185 on arrows' size.

\documentclass[border=9,tikz]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
view={0}{90},
domain=0:10,
y domain=0:5,
hide axis
]
point meta={sqrt(((2/3*x-4/15*x*y)/5)^2+((x*y/5-y)/5)^2)},
quiver={%
u={(2/3*x-4/15*x*y)/5},
v={(x*y/5-y)/5},
every arrow/.append style={%
line width=.1+\pgfplotspointmetatransformed/1000,
-{Latex[length=0pt 5,width=0pt 3]}
},
},
] {0};
\end{axis}
\end{tikzpicture}
\end{document}