Skip to main content
delete duplicate image
Source Link
Michael E2
  • 244.8k
  • 18
  • 351
  • 774

Alternative that avoids the flicker of Tooltip (copying & adapting @Nasser):

f[x_, a_] := Sin[a x^3];
p = {0, 0};
Manipulate[
 EventHandler[
  Plot[f[x, a], {x, -Pi, Pi}, 
   Prolog -> Dynamic@{Thin, 
       Line[{{p[[1]], 0}, {p[[1]], f[ p[[1]], a]}, {0, f[ p[[1]], a]}}], 
       Point[{p[[1]], f[ p[[1]], a]}]}, 
   PlotLabel -> 
    Dynamic@{p[[1]], f[ p[[1]], a]}],
  {"MouseMoved" :> (p = If[# =!= None, #, p] &@MousePosition["Graphics"])}],
{{a, 1, "a?"}, .1, 5, .1}]

Manipulate output

It also takes advantage of Plot's adaptive graphing methods to deal with wiggly graphs.

enter image description here

Alternative that avoids the flicker of Tooltip (copying & adapting @Nasser):

f[x_, a_] := Sin[a x^3];
p = {0, 0};
Manipulate[
 EventHandler[
  Plot[f[x, a], {x, -Pi, Pi}, 
   Prolog -> Dynamic@{Thin, 
       Line[{{p[[1]], 0}, {p[[1]], f[ p[[1]], a]}, {0, f[ p[[1]], a]}}], 
       Point[{p[[1]], f[ p[[1]], a]}]}, 
   PlotLabel -> 
    Dynamic@{p[[1]], f[ p[[1]], a]}],
  {"MouseMoved" :> (p = If[# =!= None, #, p] &@MousePosition["Graphics"])}],
{{a, 1, "a?"}, .1, 5, .1}]

Manipulate output

It also takes advantage of Plot's adaptive graphing methods to deal with wiggly graphs.

enter image description here

Alternative that avoids the flicker of Tooltip (copying & adapting @Nasser):

f[x_, a_] := Sin[a x^3];
p = {0, 0};
Manipulate[
 EventHandler[
  Plot[f[x, a], {x, -Pi, Pi}, 
   Prolog -> Dynamic@{Thin, 
       Line[{{p[[1]], 0}, {p[[1]], f[ p[[1]], a]}, {0, f[ p[[1]], a]}}], 
       Point[{p[[1]], f[ p[[1]], a]}]}, 
   PlotLabel -> 
    Dynamic@{p[[1]], f[ p[[1]], a]}],
  {"MouseMoved" :> (p = If[# =!= None, #, p] &@MousePosition["Graphics"])}],
{{a, 1, "a?"}, .1, 5, .1}]

Manipulate output

It also takes advantage of Plot's adaptive graphing methods to deal with wiggly graphs.

Source Link
Michael E2
  • 244.8k
  • 18
  • 351
  • 774

Alternative that avoids the flicker of Tooltip (copying & adapting @Nasser):

f[x_, a_] := Sin[a x^3];
p = {0, 0};
Manipulate[
 EventHandler[
  Plot[f[x, a], {x, -Pi, Pi}, 
   Prolog -> Dynamic@{Thin, 
       Line[{{p[[1]], 0}, {p[[1]], f[ p[[1]], a]}, {0, f[ p[[1]], a]}}], 
       Point[{p[[1]], f[ p[[1]], a]}]}, 
   PlotLabel -> 
    Dynamic@{p[[1]], f[ p[[1]], a]}],
  {"MouseMoved" :> (p = If[# =!= None, #, p] &@MousePosition["Graphics"])}],
{{a, 1, "a?"}, .1, 5, .1}]

Manipulate output

It also takes advantage of Plot's adaptive graphing methods to deal with wiggly graphs.

enter image description here