# How to plot vector field of a function with tikz?

How can I draw a vector field of a function with tikz?

For example f(x,y) = 4x2 + y2 - 5

Using pgfplots you can draw a vector field with the option quiver. This option creates a 3d vector field, but you can choose to view it 'from above' adding the view={0}{90} to the axis options.

Something like this:

\documentclass[border=2mm]{standalone}
\usepackage {pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}
\begin{tikzpicture}
\begin{axis}[%
view     = {0}{90}, % for a view 'from above'
domain   = -3:3,
y domain = -3:3,
xtick    = {-3,...,3},
ytick    = {-3,...,3},
]
\addplot3[blue, quiver={u=8*x, v=2*y, scale arrows=0.05}, samples=16, -latex] (x,y,0);

• @Juan Castano: I think the red one is the ellipse 4x^2 + y^2 =5 where the speed (velocity) of solutions of the ODE y' = 4x^2 + y^2 - 5 is vanishing. It seems to contradict with your figure. Am I wrong something? Nov 15, 2021 at 5:12