I have a list in the form of prices
below.
mcd = FinancialData["MCD", {{1990, 1, 1}, {2014, 1, 1}, "Month"}];
ibm = FinancialData["IBM", {{1990, 1, 1}, {2014, 1, 1}, "Month"},
"Value"];
hpq = FinancialData["HPQ", {{1990, 1, 1}, {2014, 1, 1}, "Month"},
"Value"];
prices = Table[
Append[hpq[[i]]]@Append[ibm[[i]]]@mcd[[i]],
{i, First@Dimensions[ibm]}];
I have prices
in this form and am not building it from FinancialData
. From this I make a DataListLogPlot
that I'd like to reindex to certain points using Manipulate
.
Manipulate[
DateListPlot[
Table[
Table[
{
prices[[i, 1]],
Table[100 (prices[[m, n]]/prices[[indexLoc, n]]),
{m, 1, Dimensions[prices][[1]]}, {n, 2, 4}][[i, j]]
},
{i, Dimensions[prices][[1]]}],
{j, Dimensions[prices][[2]] - 1}],
GridLines -> {None, Automatic}, PlotLegends -> Automatic
],
{indexLoc, 1, Dimensions[prices][[1]], 12}]
This works. It reindexes the values to 100 at the month in the series that is selected by the slider. However, it takes a while (4 seconds or so) to calculate each time it is moved. I was hoping to have this scrollable with a vertical line at the month it is reindex. However, it is too clunky with this 4 second lag. Is there a way to speed this up? I looked at a few of the time series functions but nothing jumped out at me.
Thanks,
Edmund
Update
From Sander's suggestion below I was able to get to what I wanted. I need to keep it as a DateListLogPlot
but was able to use Transpose
to get there.
(*Using the "prices" variable from above*)
plotPrices =
Table[
Table[
{
prices[[i, 1]],
Table[(prices[[m, n]]), {m, 1, Dimensions[prices][[1]]},
{n, 2, 4}][[i, j]]
},
{i, Dimensions[prices][[1]]}],
{j, Dimensions[prices][[2]] - 1}];
Manipulate[
DateListLogPlot[
Transpose[
{#[[All, 1]], 100 #[[All, 2]]/#[[indexLoc, 2]]} & /@ plotPrices,
{1, 3, 2}],
GridLines -> {None, Automatic},
PlotLegends -> Automatic],
{indexLoc, 1, Dimensions[prices][[1]], 1}]