Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems like a basic feature that is somehow missing. Ideally we'd get something like a tooltip which shows the x,y position where I click (or of where the mouse is currently hovering) and the evaluated vector (or scalar in the case of a scalar field) at that position. I think this would be a great way to "get a feel for" the values because by default the arrows are scaled automatically so they fit so I don't know anything about the relative magnitude of a particular arrow.

I have found that this is a good way to get a tooltip which displays the current mouse coordinates really well, but it obviously won't evaluate my vector field for me.

share|improve this question
For the case of scalar field plot it's quite easy to see what's going on by just doing a 3D plot with it. – Steven Lu Jul 5 '12 at 4:30
Something like VectorPlot[{y, -x}, {x, -3, 3}, {y, -3, 3}] /. ar : Arrow[{p1_, p2_}] :> Tooltip[Arrow[{p1, p2}], p1]? – J. M. Jul 5 '12 at 4:37
@J.M. That's pretty good – Steven Lu Jul 8 '12 at 20:35
up vote 7 down vote accepted

There are many ways to do this. For example, using LocatorPane. Imagine this is your vector function:

f[x_, y_] := {-1 - x^2 + y, 1 + x - y^2}

Now this will do the trick, where first line is the coordinate, and second is the function f evaluated at the coordinate. Red dot will follow the mouse. You can also bring the numbers with PlotLabel outside the graphics not to block the view.

DynamicModule[{pt = {1, 0}},LocatorPane[Dynamic[pt], 
  VectorPlot[f[x, y], {x, -3, 3}, {y, -3, 3}, StreamPoints -> Coarse, 
   StreamColorFunction -> Hue, Epilog -> Dynamic@Inset[{pt, f @@ pt}, pt], 
   PerformanceGoal -> "Quality"], AutoAction -> True, 
   Appearance -> Style["\[FilledCircle]", Red]]]

enter image description here

share|improve this answer
Since the plot itself is static you can also do VectorPlot[..., Epilog -> Dynamic[...]] instead of Dynamic[VectorPlot[....]]. On my system this makes the plot a lot more responsive. – Heike Jul 5 '12 at 9:04
@Heike Excellent point. The rule of thumb with Dynamic is to try bring it to the lowest level to avoid recomputing redundant things. I made the changes. – Vitaliy Kaurov Jul 5 '12 at 9:24
This is beautiful. – Steven Lu Jul 8 '12 at 20:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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