# Labelling Curves Using ListLogLinearPlot within DynamicModule (So Close)

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. http://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.

-
Je n’ai fait celle-ci plus longue que parce que je n’ai pas eu le loisir de la faire plus courte. –  belisarius May 7 '13 at 2:46
@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. –  Ghersic May 7 '13 at 3:32
Please consider it an opinion an not a dogmatic truth –  belisarius May 7 '13 at 3:40
@belisarius No, not at all dogmatic. I agree, there was too much detail to sift through. I've tried to trim it down without sucking the life out of it. –  Ghersic May 7 '13 at 3:52

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,
Function[{pt, interp}, {#, interp@Exp@#} &@ Clip[First@pt, Log@interp["Domain"][[1]]]],
{#, interps}]) &],
Show[myplot,
Graphics[{Dynamic @ Table[Inset[
pos[[i]]], {i, 3}]}]],
Appearance -> None
]
]


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.
-
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 –  Ghersic May 7 '13 at 4:03
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 –  Ghersic May 7 '13 at 4:23