1
$\begingroup$

I already have draw the Contour Plot and I know how Vector Plot a field of vectors. But the problem is how can I draw only one vector (at a specific point) of the gradient in the Contour Plot?

$\endgroup$
1
$\begingroup$

Here's an example that uses Epilog and Arrow to add a single vector to a contour plot. The vector represents the gradient of the function that is being plotted. The Grad function is used to calculate the gradient.

f[x_, y_] := Sin[x] + Cos[y]
r = {x -> Pi/2, y -> 2.1};
pt1 = {x, y} /. r;
pt2 = pt1 + Grad[f[x, y], {x, y}] /. r;
ContourPlot[f[x, y] == 1/2, {x, 0, Pi}, {y, 0, Pi},
 Epilog -> {Red, Arrow[{pt1, pt2}]}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.