Group Abstract Group Abstract

Message Boards Message Boards

Tracing curve in a Graphic (Position Data?)

Posted 12 years ago
POSTED BY: Zach Wolfe
4 Replies

If not use tooltip, I propose to plot with Text.

data = Table[{x, Cos[x]}, {x, -Pi, Pi, Pi/8}]
Graphics[Text[#[[2]], #] & /@ data]

plot with text

POSTED BY: Yu(u)ki IWABUCHI

Here is a crude preliminary version of what Szabolics hinted at:

CursorPlot[f_] := Module[{plot, max,},
   plot = Plot[f[x], {x, -2 Pi, 2 Pi}];

   (*calculate max bounds*)
   max = 1.1 Max@Abs@Flatten@
        (PlotRange /. AbsoluteOptions[plot]);

   Show[
    Plot[f[x], {x, -2 Pi, 2 Pi}],

    Graphics[Dynamic[Module[
       {x = (MousePosition["Graphics"] /. None -> {0, 0})[[1]]},

       {Gray,
        Line[{{x, -max}, {x, max}}],
        Line[{{-max, f[x]}, {max, f[x]}}],
        Black,
        Text["O", {x, f[x]}],
        Text[StringJoin[ToString /@ {
            "\n\n\t\t\t(", x, ", ", f[x], ")"}], {x, f[x]}]}

       ]]]]];

CursorPlot[Sin[#] &]

There's better ways to do a lot of what's here but this will at least give you a few ideas. Mainly it is the usage of Show in combination with Dynamic and MousePosition["Graphics"]. As always, it's a good idea to F1 any symbol/function you're unfamiliar with.

POSTED BY: Szabolcs Horvát

I am not sure if this is answering you, But if you want to trace values on curve, ToolTip will work

data = Table[Tooltip[N@{x, Cos[x]}], {x, -Pi, Pi, .05}];
ListPlot[data, Joined -> True, Mesh -> Full]

Note: have to use Mesh->Full for the tooltip to show.

enter image description here

POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard