Date Visualization

Nirmal Malapaka, Wolfram Research

Join the Conversation #WolframTechConf

Contents

Basics of Dates

Date Visualizations Features

Date Visualizations Options

Date Visualizations Applications

Conclusion

Introduction

Basics

AbsoluteTime

DateString

DateList

DateObject

TimeSeries

EventSeries

TemporalData

Wolfram Data Sources (Financial Data, Entity Framework, Wolfram|Alpha)

Introduction

AbsoluteTime

AbsoluteTime[{1900,1,1}]

DateListPlot[{{3368649600,10},{3369859200,20},{3371155200,5},{3372969600,10}},PlotTheme->"Web"]

DateString

DateListPlot[{{"June 2006",10},{"August 2006",20},{"November 2006",5},{"January 2007",10}},PlotTheme->"Web",ScalingFunctions->"Reverse"]

DateList

DateListPlot[{{{2006,6},10},{{2006,8},2000},{{2006,11},5},{{2007,1},100}},PlotTheme->"Web",ScalingFunctions->"Log"]

DateObject

DateListPlot[{{(DateObject["Jun 2006", DateObject[{2006,6}]]),10},{(DateObject["Aug 2006", DateObject[{2006,8}]]),20},{(DateObject["Nov 2006", DateObject[{2006,11}]]),5},{(DateObject["Jan 2007", DateObject[{2007,1}]]),10}},PlotTheme->"Web",ScalingFunctions->"Reverse"]

TimeSeries

v={10,20,5,10};

t={(DateObject["Jun 2006", DateObject[{2006,6}]]),(DateObject["Aug 2006", DateObject[{2006,8}]]),(DateObject["Nov 2006", DateObject[{2006,11}]]),(DateObject["Jan 2007", DateObject[{2007,1}]])};

ts=TimeSeries[v,{t}]

DateListPlot[ts,PlotTheme->"Web"]

EventSeries

v={10,20,5,10};

t={(DateObject["Jun 2006", DateObject[{2006,6}]]),(DateObject["Aug 2006", DateObject[{2006,8}]]),(DateObject["Nov 2006", DateObject[{2006,11}]]),(DateObject["Jan 2007", DateObject[{2007,1}]])};

ts=EventSeries[v,{t}]

DateListPlot[ts,PlotTheme->"Web",Joined->False,Filling->Axis]

christmas=(Last/@(Most[DayRange[DateString[{#,1}],DateString[{#+1,1}],"Holiday", HolidayCalendar->"UnitedStates"]]&/@Range[2000,2016,1]))

DateListStepPlot[EventSeries[#["Day"]&/@christmas,{christmas}],PlotRange->{Automatic,{20,30}},PlotMarkers->Automatic,GridLines->{{{2005,1,1}},None}]

DateListStepPlot[#["Day"]&/@christmas,{{2000,12,25},Automatic,"Year"},PlotRange->{Automatic,{20,30}},PlotMarkers->Automatic,GridLines->{{{2005,1,1}},None}]

Wolfram Data

data=FinancialData["AAPL","Close",{{2015,5,1},Today}];

RenkoChart[data]

Visualizations

Dates

Date visualization functions can take data from a variety of forms. Dates can be specified as objects, strings, or lists.

opts={PlotTheme->"Web",ImageSize->350};
d=DateRange[{2000,1,1},{2000,12,1},{5,"Hour"}];
data=RandomVariate[NormalDistribution[1,3],5 10^2]~Join~RandomVariate[NormalDistribution[10,2],5 10^2];
data=Rescale[data,MinMax[data],{1,Length[d]}];
daterange=Part[d,Round[data]];
dateobjects=DateObject[#,TimeZone->Automatic]&/@daterange;
association=Association[Thread[Range[Length[daterange]]->dateobjects]];
timeseries=TimeSeries[Transpose[{dateobjects,Range[Length[daterange]]}]];
eventseries=EventSeries[Range[Length[daterange]],{dateobjects}];
weighteddata=WeightedData[dateobjects,Table[2,{Length[daterange]}]];
datestrings=DateString/@dateobjects;
absolutetime=AbsoluteTime/@daterange;
Grid[{{Pane[Short[dateobjects,3],350],DateHistogram[daterange,20,opts]},{Pane[Short[datestrings,3], 350], DateHistogram[datestrings, 20, opts]},{Pane[Short[daterange,3], 350], DateHistogram[daterange, opts]}},Dividers->All,Alignment->{Center,Center}]

Time series and event series use time stamps, ignoring the corresponding values.

Grid[{{Pane[Short[timeseries],350],DateHistogram[timeseries,20,opts]},{Pane[Short[eventseries],350],DateHistogram[eventseries,20,opts]}}, Dividers -> All, Alignment -> {Center, Center}]

For associations, the values are used, ignoring the corresponding keys.

Grid[{{Pane[Short[association,3],350],DateHistogram[association,20,opts]}}, Dividers -> All, Alignment -> {Center, Center}]

Visualizations

DateHistogram

DateHistogram[timeseries,20]

MinMax[timeseries]

Histogram[timeseries,20]

data=DayRange[DateString[{2016,1}],DateString[{2017,1}],"Holiday", HolidayCalendar->#]&/@DeleteCases[CountryData["G8"],Entity["Country","France"]];

countries=DeleteCases[CountryData["G8"],Entity["Country","France"]];

DateHistogram[data,"Month",ChartLegends->countries,ChartLayout->"Stacked"]

Visualizations

TimelinePlot

TimelinePlot[data,PlotLegends->countries]

ndata={Tooltip[{Labeled[(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),"New Year"],(DateObject["Mon 15 Feb 2016", DateObject[{2016,2,15}]]),(DateObject["Fri 25 Mar 2016", DateObject[{2016,3,25}]]),(DateObject["Mon 23 May 2016", DateObject[{2016,5,23}]]),(DateObject["Fri 1 Jul 2016", DateObject[{2016,7,1}]]),(DateObject["Mon 1 Aug 2016", DateObject[{2016,8,1}]]),(DateObject["Mon 5 Sep 2016", DateObject[{2016,9,5}]]),(DateObject["Mon 10 Oct 2016", DateObject[{2016,10,10}]]),(DateObject["Fri 11 Nov 2016", DateObject[{2016,11,11}]]),Tooltip[(DateObject["Mon 26 Dec 2016", DateObject[{2016,12,26}]]),LinguisticAssistant],Tooltip[(DateObject["Tue 27 Dec 2016", DateObject[{2016,12,27}]]),"Christmas"]},LinguisticAssistant],Tooltip[{Labeled[(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),"New Year"],(DateObject["Fri 25 Mar 2016", DateObject[{2016,3,25}]]),(DateObject["Mon 28 Mar 2016", DateObject[{2016,3,28}]]),(DateObject["Mon 26 Dec 2016", DateObject[{2016,12,26}]])},LinguisticAssistant],Tooltip[{(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),(DateObject["Wed 6 Jan 2016", DateObject[{2016,1,6}]]),(DateObject["Mon 28 Mar 2016", DateObject[{2016,3,28}]]),(DateObject["Mon 25 Apr 2016", DateObject[{2016,4,25}]]),(DateObject["Thu 2 Jun 2016", DateObject[{2016,6,2}]]),(DateObject["Mon 15 Aug 2016", DateObject[{2016,8,15}]]),(DateObject["Tue 1 Nov 2016", DateObject[{2016,11,1}]]),(DateObject["Thu 8 Dec 2016", DateObject[{2016,12,8}]]),(DateObject["Mon 26 Dec 2016", DateObject[{2016,12,26}]])},LinguisticAssistant],Tooltip[{(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),(DateObject["Mon 11 Jan 2016", DateObject[{2016,1,11}]]),(DateObject["Thu 11 Feb 2016", DateObject[{2016,2,11}]]),(DateObject["Mon 21 Mar 2016", DateObject[{2016,3,21}]]),(DateObject["Fri 29 Apr 2016", DateObject[{2016,4,29}]]),(DateObject["Tue 3 May 2016", DateObject[{2016,5,3}]]),(DateObject["Wed 4 May 2016", DateObject[{2016,5,4}]]),(DateObject["Thu 5 May 2016", DateObject[{2016,5,5}]]),(DateObject["Mon 18 Jul 2016", DateObject[{2016,7,18}]]),(DateObject["Mon 19 Sep 2016", DateObject[{2016,9,19}]]),(DateObject["Thu 22 Sep 2016", DateObject[{2016,9,22}]]),(DateObject["Mon 10 Oct 2016", DateObject[{2016,10,10}]]),(DateObject["Thu 3 Nov 2016", DateObject[{2016,11,3}]]),(DateObject["Wed 23 Nov 2016", DateObject[{2016,11,23}]]),(DateObject["Fri 23 Dec 2016", DateObject[{2016,12,23}]])},LinguisticAssistant],Tooltip[{(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),(DateObject["Mon 4 Jan 2016", DateObject[{2016,1,4}]]),(DateObject["Tue 5 Jan 2016", DateObject[{2016,1,5}]]),(DateObject["Wed 6 Jan 2016", DateObject[{2016,1,6}]]),(DateObject["Thu 7 Jan 2016", DateObject[{2016,1,7}]]),(DateObject["Fri 8 Jan 2016", DateObject[{2016,1,8}]]),(DateObject["Tue 23 Feb 2016", DateObject[{2016,2,23}]]),(DateObject["Tue 8 Mar 2016", DateObject[{2016,3,8}]]),(DateObject["Mon 2 May 2016", DateObject[{2016,5,2}]]),(DateObject["Mon 9 May 2016", DateObject[{2016,5,9}]]),(DateObject["Mon 13 Jun 2016", DateObject[{2016,6,13}]]),(DateObject["Fri 4 Nov 2016", DateObject[{2016,11,4}]])},LinguisticAssistant],Tooltip[{(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),(DateObject["Fri 25 Mar 2016", DateObject[{2016,3,25}]]),(DateObject["Mon 28 Mar 2016", DateObject[{2016,3,28}]]),(DateObject["Mon 2 May 2016", DateObject[{2016,5,2}]]),(DateObject["Mon 30 May 2016", DateObject[{2016,5,30}]]),(DateObject["Mon 29 Aug 2016", DateObject[{2016,8,29}]]),(DateObject["Mon 26 Dec 2016", DateObject[{2016,12,26}]]),(DateObject["Tue 27 Dec 2016", DateObject[{2016,12,27}]])},LinguisticAssistant],Tooltip[{(DateObject["Fri 1 Jan 2016", DateObject[{2016,1,1}]]),(DateObject["Mon 18 Jan 2016", DateObject[{2016,1,18}]]),(DateObject["Mon 15 Feb 2016", DateObject[{2016,2,15}]]),(DateObject["Mon 30 May 2016", DateObject[{2016,5,30}]]),Labeled[(DateObject["Mon 4 Jul 2016", DateObject[{2016,7,4}]]),"Independence Day"],(DateObject["Mon 5 Sep 2016", DateObject[{2016,9,5}]]),(DateObject["Mon 10 Oct 2016", DateObject[{2016,10,10}]]),(DateObject["Fri 11 Nov 2016", DateObject[{2016,11,11}]]),(DateObject["Thu 24 Nov 2016", DateObject[{2016,11,24}]]),(DateObject["Mon 26 Dec 2016", DateObject[{2016,12,26}]])},LinguisticAssistant]};
TimelinePlot[ndata,PlotLegends->countries]

Visualizations

DateListPlot

DateListPlot[MapIndexed[{#,First[#2]}&,#]&/@data,PlotLegends->countries,Joined->False]

DateListStepPlot

MapThread[DateListStepPlot[#,PlotRange->{{"Jan 1, 2016","Dec 31, 2016"},{0,16}},PlotTheme->"Web",PlotStyle->Hue[Rescale[#2,{0,9.7}]],PlotLabel->#3]&,{MapIndexed[{#,First[#2]}&,#]&/@data,Length/@data,countries}]

Options

GridLines, PlotRange

Show[MapThread[DateListStepPlot[Legended[#,CountryData[#3]["Name"]],PlotRange->{{"Jan 1, 2016","Dec 31, 2016"},{0,16}},PlotStyle->Hue[Rescale[#2,{0,9.7}]],GridLines->{{{"July 4 2016",Directive[Blue,Thick,Dashed]}},None}]&,{MapIndexed[{#,First[#2]}&,#]&/@data,Length/@data,countries}]]

DateFunction

DateListPlot[MapIndexed[{#,First[#2]}&,#]&/@data,InterpolationOrder->0,PlotLegends->countries, DateFunction:>(DayRound[#,"EndOfMonth"]&)]

Options

DateTicksFormat

DateHistogram[data,ChartLayout->"Stacked"]

Grid[Partition[DateHistogram[data,DateTicksFormat->#,ChartLayout->"Stacked"]&/@{"Year","YearShort","QuarterNameShort","MonthNameShort"},2]]

({{, }, {, }})

({{      , "Year", full year (e.g. 2005)}, {      , "YearShort", 2-digit year (e.g. 05)}, {      , "QuarterNameShort", quarter of year in short form (e.g. "Q1")}, {      , "MonthNameShort", month name in short form (e.g. "Aug")}, {      , "MonthNameInitial", first letter of month name (e.g. "A")}, {      , "Month", 2-digit month number (e.g. 08)}, {      , "MonthShort", 1- or 2-digit month number (e.g. 8)}, {      , "DayNameShort", short day of the week (e.g. "Wed")}, {      , "DayNameInitial", first letter of day name (e.g. "W")}, {      , "Day", 2-digit day of the month (e.g. 09)}, {      , "DayShort", 1- or 2-digit day of the month (e.g. 9 or 29)}, {      , "Hour12", hour on 12-hour clock}, {      , "Hour24", hour on 24-hour clock}, {      , "AMPM", AM or PM}, {      , "AMPMLowerCase", am or pm}, {      , "Minute", 2-digit minute (e.g. 05)}, {      , "Second", 2-digit seconds}})

DateReduction

DateHistogram[data,"Day",ChartLegends->countries,ChartLayout->"Stacked",DateReduction->"Month"]

TimeZone

DateHistogram[data,"Month",ChartLayout->"Stacked",TimeZone->-6,ChartLegends->countries]

DateHistogram[data,"Month",ChartLayout->"Stacked",ChartLegends->countries]

Application

TradingChart (Financial Data, TimeSeries)

InteractiveTradingChart[{"INTC",{{2016,1,1},Today}}]

Application

Git Histogram

lhd=Import["/home/nirmal/Downloads/Mathematica/WTC2016/histrawdat.txt","TSV"]

slhd=StringSplit[#,"-"|"+"]&@@@lhd

jslhd={StringJoin[Riffle[Most[#]," "]],Last[#]}&/@slhd

linhistdat=DateObject[#,TimeZone->(((ToExpression[#2]/100))/.(a_Rational:>Quotient[Numerator[a],10]+.5))]&@@@jslhd

tux=Import["/home/nirmal/Downloads/Mathematica/WTC2016/tux.png"];

DateHistogram[linhistdat,"Year"]

MinMax[linhistdat]

f=(DateObject[{2005,1}]<#<Today)&;

clinhistdat=Cases[linhistdat,x_/;f[x]]

Application

Git Histogram

linuxH=DateHistogram[clinhistdat,"Year",ChartElements->tux,DateTicksFormat->{"Year"}]

linuxH=DateHistogram[clinhistdat,"Month",ChartElements->tux,DateReduction->"Year"]

linuxH=DateHistogram[clinhistdat,"Year",ChartElements->LinguisticAssistant,DateTicksFormat->{"Year"}]

Application

Git Histogram

linushd=Import["/home/nirmal/Downloads/Mathematica/WTC2016/linuxrawdata.txt","TSV"]

slinushd=StringSplit[#,"-"|"+"]&@@@linushd

jslinushd={StringJoin[Riffle[Most[#]," "]],Last[#]}&/@slinushd

linushistdat=DateObject[#,TimeZone->(((ToExpression[#2]/100))/.(a_Rational:>Quotient[Numerator[a],10]+.5))]&@@@jslinushd

KeyMap[DateObject[{#}]&,CountsBy[linushistdat,(#["Year"])&]]

linusH=DateListPlot[KeyMap[DateObject[{(#),7}]&,CountsBy[linushistdat,(#["Year"])&]],"Year",PlotRange->{{{2005,1},{2017,1}},Automatic},PlotStyle->{Red,Thick},PlotMarkers->Automatic,DateTicksFormat->"Year"]

Application

Git Histogram

Show[linuxH,linusH]

Application

ClockGauge

DynamicModule[{t=(t=None)},
Column[{
Dynamic[ActionMenu["Update Time:",{"On":>(t=(UpdateInterval->1);),"Off":>(t=None;)}]],
Dynamic[Refresh[Row[{ClockGauge[AbsoluteTime[],PlotLabel->Style["Local",Large,Bold]],ClockGauge[AbsoluteTime[TimeZone->0],PlotLabel->Style["London",Large,Bold]],
ClockGauge[AbsoluteTime[TimeZone->-5],PlotLabel->Style["New York",Large,Bold]],ClockGauge[AbsoluteTime[TimeZone->-8],PlotLabel->Style["Los Angeles",Large,Bold]]}],t]]
},Alignment->Center]
]

Addenda

Thu, Oct 20th
1:00 PM - 1:30 PM
Spartan/Golden Gopher
Time Series Processing
Gosia Konwerska
Wolfram Research

https : // www.wolfram.com/mathematica/new - in - 11/

Survey

Thank You