I don't have that package installed, but I will give you an example which can surly be extended to your situation. The basic principle should be clear: You want to select (by Slider
or whatever) a certain time and then plot this point dynamically over your DateListPlot
. Let's say we have a simple plot of financial data like this
My approach will extract the drawn points from this graphics and gives you the opportunity to trace them. First, you need to understand how Mathematica draws such graphs and this is why I want you to look at the internal representation of a very simple plot. The first part of each Graphics
are the graphics primitives which define what is plotted. Look at this
data = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12},
{{2006, 10, 30}, 15}, {{2006, 11, 20}, 20}};
DateListPlot[data][[1]]
and see that beside setting some colors, the curve is drawn with a Line
primitive. Therefore, what I will do is use Cases
to extract the expression matching Line[pts_]
in the plot. Then I will use these points and put it inside a Manipulate
. For convenience, I will extract the currently used point, max, min, ... values, so that I don't have to write pts[[...]]
over and over again.
The rest is to create a new graphics that shows the current point, two helping lines and a label. Everything is then put together with the original plot using Show
. I have inserted empty lines in the code, so that you can see the single steps I have explained:
With[{dlp = DateListPlot[FinancialData["IBM", "Jan. 1, 2004"]]},
With[{pts = First@Cases[dlp, Line[pts_] :> pts, Infinity]},
Manipulate[
Module[{mint, maxt, minv, maxv, t, v},
{{mint, maxt}, {minv, maxv}} = {Min[#], Max[#]} & /@ Transpose[pts];
{t, v} = pts[[i]];
Show[dlp,
Graphics[{ColorData[5, 2], Thickness[.005], PointSize[0.02],
Line[{{mint, v}, {t, v}, {t, 0}}], Point[{t, v}],
Text[Style[DateString[t, {"DateShort"}] <> ": " <> ToString[v], 12,
Background -> Opacity[.7, White]], {t, v}, {-1, -2}]}]
]],
{i, 1, Length[pts], 1}]
]
]