How can dates be formatted with Tooltip in a DateListPlot?
Here's one way:
stocks = {"AAPL", "FB"};
prices = FinancialData[stocks, {{2019, 11, 1}, {2019, 11, 15}}];
stockPrices = AssociationThread[stocks, prices];
tooltip[expr : {date_, value_}] := Tooltip[expr, DateString[date]]
DateListPlot[
(tooltip /@ Normal[#]) & /@ stockPrices
]
An alternative procedure is to recognize that DateListPlot[]
uses absolute time as the abscissa, and then construct a replacement rule using DateString[]
. Using the same data as in C.E.'s answer:
DateListPlot[Tooltip[stockPrices]] /.
Tooltip[obj_, {at_, val_}] :> Tooltip[obj, DateString[at]]
Use the second argument of DateString[]
if you want to modify the format used in the tooltips.