1

Mouseover is defined as Mouseover[expr,over]. I have a plot on the left and a graphic on the right. Can I use Mouseover on the right graphic (expression) and have the result (over) show up on the left plot?

For example, I move my mouse over the top stage rectangle and as a result, "stage 1" shows up on the plot on the left. Is this possible?

enter image description here

Here is my code:

Module[{y1, y2, p1, p2},
 y1[x_] := 100*(x - 0.05) + 10;
 y2[x_] := 84.48*x;

 p1 = Plot[{y1[x], y2[x]}, {x, 0, 0.7}, PlotRangePadding -> None, 
   PlotStyle -> {{Thick, Black}, {Thick, Blue}},
   Frame -> True, 
   FrameLabel -> {Style["X", Italic], Style["Y", Italic]}, 
   LabelStyle -> {17, Black}, ImageSize -> {400, 400}, 
   AspectRatio -> Full];

 p2 = Graphics[{
    {EdgeForm@Thick, FaceForm@None, 
     Rectangle[{0, #}, {1, # + 0.5}] & /@ Range@5},

    {Arrowheads@0.25,
     Arrow[{{0.25, # - 0.5}, {0.25, #}}] & /@ Range[2, 5],
     Arrow[{{0, 0.5}, {0.25, 0.5}, {0.25, 1}}], 
     Arrow[{{0.25, 5.5}, {0.25, 6}, {0, 6}}],
     Arrow[{{0.75, #}, {0.75, # - 0.5}}] & /@ Range[2, 5],
     Arrow[{{0.75, 1}, {0.75, 0.5}, {1, 0.5}}], 
     Arrow[{{1, 6}, {0.75, 6}, {0.75, 5.5}}]},

    Text[Style[6 - #, 17, Background -> White], {0.5, 0.25 + #}] & /@ 
     Range@5
    }, ImageSize -> {200, 400}];

 Grid@{{p1, p2}}
 ]
Kuba
  • 136,707
  • 13
  • 279
  • 740
baumannr
  • 787
  • 3
  • 10

1 Answers1

1

For simple cases it is a job for Annotation:

{ Annotation[Framed[1], "Stage 1", "Mouse"]
, Graphics[{Circle[], Inset@Dynamic[MouseAnnotation[""]]}]
}

For more complicated you can make use of EvenHandler and related events: "MouseMoved", "MouseEntered", "MouseExited".

See:

Kuba
  • 136,707
  • 13
  • 279
  • 740