I want to show the coordinates of the (mouse) pointing device as I move the pointing device over the VectorPlot without a (right or left) click. I have tried ToolTip and MousePosition but I cannot get either to work for me. The code below is pared down version based on a suggestion from Belisarius:

Manipulate[

sol[t_, t0_, x0_] :=

x[t] /. First[

NDSolve[{x'[t] + x[t] == 0, x[t0] == x0}, x[t], {t, -2, 2}]];

ClickPane[

Show[ Plot[g, {t, -2, 2}, PlotRange -> 1, Frame -> True], sf,

Epilog -> {PointSize[Large], Point[sp]}],

(AppendTo[g, sol[t, #[[1]], #[[2]]]]; {t0, x0} = #;

AppendTo[sp, #]) &],

Initialization :> {(g = {}; sp = {}; {x0, t0} = {-1, -1}),

sf := VectorPlot[{1, -x}, {t, -2, 2}, {x, -1, 1},

VectorPoints -> 17, VectorScale -> {0.03, Automatic, None},

VectorStyle -> {{Red, Arrowheads[0]}},

PerformanceGoal -> “Speed”]}

]

I realize that I need to use Dynamic but the ClickPane seems to mess me up. I need to maintain the functionality of saving the “clicked solutions.”

=================

=================

1 Answer

1

=================

Clear[xp]

xp[t_, r_, t0_, x0_] := x[t] /.

First[NDSolve[{x'[t] + r x[t] == 0, x[t0] == x0}, x[t], {t, 0, 10}]];

Manipulate[

ClickPane[ Plot[g, {t, 0, 10}, PlotRange -> 1, Frame -> True,

PlotLabel -> Dynamic[MousePosition[“Graphics”]],

Epilog -> {PointSize[Large], Point[sp]}],

(AppendTo[g, xp[t, r, #]]; AppendTo[sp, #]) &],

{{r, 1, “r”}, -10, 10, 0.01, ImageSize -> Tiny, Appearance -> “Labeled”},

Button[“clear”, {g = {}; sp = {}}, ImageSize -> {40, 20}],

Initialization :> (g = {}; sp = {})]

I took the liberty of adding the definition of xp from the link, to make your answer self-contained. Very neat! I had missed it before (+1).

– MarcoB

Aug 28 ’15 at 13:33

@MarcoB Thanks! I ran the code from the other answer, and you know … lingering definitions 🙂

– Dr. belisarius

Aug 28 ’15 at 13:46

@MarcoB Nice! I will add your PlotLabel to the original code .

– Stephen

Aug 29 ’15 at 1:39