0

I am plotting a vector field from an external file using this MWE (the data is located here):

\documentclass{standalone}
\usepackage{pgfplots}


\begin{document}
\begin{tikzpicture}
\begin{axis}[title=Quiver and plot table]
\addplot[blue,quiver={u=\thisrow{u},v=\thisrow{v}},-stealth] table {vector_field.dat};
\end{axis}
\end{tikzpicture}
\end{document} 

There are a few things I would like to add to the plot:

  1. Only the arrowheads are shown, is it possible to add the body of the arrows as well?
  2. Is it possible to scale the lengths of the arrow heads and bodies such that they are consistent relative to each other?

Output

1

1 Answer 1

2

The arrow bodies are here, but tiny. Use the pgfplots/quiver/arrows scale key to make them bigger.

Unfortunately, your data is uneasy to plot as a quiver, due to strong variations of the values.

Maybe you should scale them non-linearly (e.g. replace the norm of the arrows by some logarithm of their norm)

Also some good (maybe better) suggestions are given in comments.

See also the second version, below, that looks better.

enter image description here

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[title=Quiver and plot table]
    \addplot
    [
      blue,
      quiver=
      {
        u=\thisrow{u},
        v=\thisrow{v},
        scale arrows=200, %to be adjusted
      },
      -stealth
    ] 
    table {vector_field.dat};
  \end{axis}
\end{tikzpicture}
\end{document} 

Another version, taken from the pgfplots manual.

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}

\begin{document}

% define some constants:
\def\U{\thisrow{u}}
\def\V{\thisrow{v}}
\def\LEN{(sqrt((\U)^2 + (\V)^2)}

\begin{tikzpicture}
  \begin{axis}[title=Quiver and plot table]
    \addplot
    [
      blue,
      point meta={\LEN},
      quiver=
      {
        u={(\U)/\LEN}, v={(\V)/\LEN},
        scale arrows=.2,
        every arrow/.append style=
        {
          line width=2pt*\pgfplotspointmetatransformed/1000
        },
      },
      -stealth
    ] 
    table {vector_field.dat};
  \end{axis}
\end{tikzpicture}
\end{document}  

yielding : enter image description here

Cheers,

Not the answer you're looking for? Browse other questions tagged .