1
$\begingroup$

I currently have a large number of time-series datasets in the form where the name and time-series transposed data, so I have a list of lists of names for datasets and their time-dependant data.

The end goal is to graph a plot which I already have as I want it by itself, only with a legend that is, with other graphics, finished as well. Within this expression for myPlot I am able to generate the labels I need via inserting an Epilog expression, producing

SetAttributes[tt, Listable] tt[name_ -> data_] := Tooltip[data, name] (Just for manipulation)

(1) myPlot = ListLogLinearPlot[#, Epilog -> Table[Inset[Framed[DisplayForm[names[[i]]], RoundingRadius -> 5, Background -> White], {5.5, 25}], {i, len}]]

(2) myPlot /@ tt[thirds@ruleData] // Column

which together yield a plot with unmovable labels for each dataset ((2) actually yields the plots with or without Epilog / labels, as specified by (1), whereas (1) alone unsquelched yields itself back in text-only output).

But I am unable to combine these expressions with DynamicModule as another post on the Stack Forums suggests. https://stackoverflow.com/questions/7221315/how-do-i-label-different-curves-in-mathematica

However, on top of a dummy graphic (table "pos" rather than plot) I can get DynamicModule to have movable labels:

DynamicModule[{pos = Table[{names[[i]]}, {i, len}]}, LocatorPane[Dynamic[pos], Appearance -> Table[Framed[Text@TraditionalForm[names[[i]]], RoundingRadius -> 5,Background -> White], {i, len}]]]

So, I would think the only problem then is figuring out how to "insert" the myPlot function(s) into DynamicModule.

I am almost certain the presence of the # in my ListLogLinearPlot function is the culprit. I need to combine these expressions labels are movable ON the graph just as they are on the dummy table.

Thank you again, I deeply appreciate any resposnes.

$\endgroup$
3
  • 1
    $\begingroup$ Je n’ai fait celle-ci plus longue que parce que je n’ai pas eu le loisir de la faire plus courte. $\endgroup$ Commented May 7, 2013 at 2:46
  • $\begingroup$ @belisarius Sorry, I will edit it to make it shorter... I just didn't want to leave anyone without a detail they needed. I'll try to omit excesses. $\endgroup$
    – Ghersic
    Commented May 7, 2013 at 3:32
  • $\begingroup$ Please consider it an opinion an not a dogmatic truth $\endgroup$ Commented May 7, 2013 at 3:40

1 Answer 1

3
$\begingroup$

Here's a guess at what you're after:

SeedRandom[1];
data = Accumulate[RandomReal[{-0.2, 0.2}, 300]];
thirds = Partition[data, 100];
interps = Interpolation /@ thirds;
myplot = ListLogLinearPlot[thirds];

DynamicModule[{pos = MapThread[{Log@#, #2[#]} &, {{5, 16, 50}, interps}]}, 
 LocatorPane[
  Dynamic[pos,
    (pos = MapThread[
       Function[{pt, interp}, {#, interp@Exp@#} &@ Clip[First@pt, Log@interp["Domain"][[1]]]],
       {#, interps}]) &],
  Show[myplot,
    Graphics[{Dynamic @ Table[Inset[
                 Framed[Text@TraditionalForm[i], RoundingRadius -> 5, Background -> White],
                 pos[[i]]], {i, 3}]}]],
  Appearance -> None
  ]
 ]

List plot with movable labels

Notes;

  1. pos should be a list of points, not myplot.
  2. The plot should be the back of LocatorPane.
  3. The second argument of Dynamic constrains the Locators to follow the plot; the interpolations interps are used to determine the y-coordinates.
  4. The Locators are given no Appearance, but they're still there and are used to place the labels.
  5. Elements of the back that change should be wrapped inside a Dynamic.
$\endgroup$
2
  • $\begingroup$ Thank you. I've entered that verbatim in Mathematica and like that the labels are not only movable by mouse, they are bound to their respective functions. I'll see if I can integrate this with my notebook! @Michael $\endgroup$
    – Ghersic
    Commented May 7, 2013 at 4:03
  • $\begingroup$ That is, on the data you've given I mean. I still need to work it into the notebook... now to figure out how to use thirds in ListLogLinearPlot given thirds[lst_List] := Partition[lst, #, #, 1, {}] &@Ceiling[Length@lst/3] or a functional equivalent. Sorry, I'm very new, I'll be back when I've progressed. @Michael $\endgroup$
    – Ghersic
    Commented May 7, 2013 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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