# Quiver plot with scaled arrowheads

This is a follow-up question to this one.

Here is a MWE showing the problem:

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{grffile}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}

\begin{axis}[%
width=5.167in,
height=3.622in,
at={(0.867in,0.489in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0,
xmax=1,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
ymin=0,
ymax=0.45,
axis background/.style={fill=white}
]
point meta={sqrt((\thisrow{u})^2+(\thisrow{v})^2)},
quiver={u=\thisrow{u},v=\thisrow{v},
every arrow/.append style={-{Straight Barb[scale length={max(0.01,\pgfplotspointmetatransformed/1000)},scale width={0.5*max(0.01,\pgfplotspointmetatransformed/1000)}]}}}
]
table[row sep=crcr]{
%
x   y   u   v\\
0   0   0.45    0.45\\
1   0   -0.45   0.45\\
};
\end{axis}
\end{tikzpicture}%
\end{document}


And here is the output: The problem is that the arrowheads are extremely small!

• Change max(0.01, ...  to max(10, ...
– Jake
Jul 7, 2015 at 18:12
• Thanks @Jake that does work. So since both vectors are the same length \pgfplotspointmetatransformed defaults to 0?
– OSE
Jul 7, 2015 at 18:14
• It looks like adding point meta min=0 makes sure that \pgfplotspointmetatransformed isn't 0 when the arrow length is non-zero. To get reasonable sized arrows I still need to add a scaling factor on the computed length though.
– OSE
Jul 7, 2015 at 18:23
• In your real code (I assume this is just a simplified example), do you want the arrowheads to all have the same size, or do they depend on the vector length?
– Jake
Jul 7, 2015 at 19:10
• Yes this is just a simplified example. I would like them to have a size proportional to the vector length, similar to the default output of MATLAB's quiver function.
– OSE
Jul 7, 2015 at 19:16