class: center, middle, inverse, title-slide .title[ # Lesson 5: It’s About Time
Visualising and Analysing Time-Oriented Data ] .author[ ### Dr. Kam Tin Seong
Assoc. Professor of Information Systems ] .institute[ ### School of Computing and Information Systems,
Singapore Management Uniiversity ] .date[ ### 2020/02/17 (updated: 2022-05-13) ] --- # What will you learn from this lesson? .vlarge[ - Characteristics of time-series data - Classic ways of graphing time - Time-series patterns - Time-series data visualization - Interactive techniques for time-series data visualisation ] ??? In this lesson, I am going to share with you methods and best practice for visualising and analysing time-series data. It is organised into five main sections. First, we will examine different format of time series data. This is followed by a review of selected inspiring data visualisation for revealing time series patterns. In section three, we will examine different time-series patterns graphically. In section 4, I will introduce selected not so commonly used time-series data visualisation techniques. Lastly, in section 5, we will examine how interactivity and animation can be used to enhance visual time-series data discovery. --- ## Characteristics of time-series data ### A typical time-series data table .center[ ] ??? The data table shows a typical time-series data. The first column contains the time series values in calender month and year. It is important to note that the values must not be in character data type. The next four columns are called time-series variables. They can be categorical or numeric data type. --- ## Characteristics of time-series data ### Not so friendly time-series data .center[ ] ??? The data table in this slide is an example of time-series data which was not organised in machine understandable time-series manner. As shown on the slide earlier, a machine understandable time-series data must be organised in rows and columns whereby of of the column must contain the date/time values. In this example, the data need to be reformatted before they can be visualised. --- ## Characteristics of time-series data ### Not so friendly time-series data .center[ ] ??? This slide shows a typical reporting table with many formatting features such as column sub-total, row sub-total, spacing, rows separators etc. Again, this table need to be tidied before it can be used to build tiem-series visualisation effectively. --- ## Characteristics of time-series data ### Not so friendly time-series data .center[ ] ??? The table on the slide is another good example of not so friendly time-series data set. As you can see, the temporal field was splitted into three columns and the Year and Day fields are in numeric and Month field is in character. Also note that many rows for Year and Month fields were empty. In view of this, this data also need to be tidied before it can be used to build data visualisation. --- ## A short visual history of time-series graphs ### Playfair’s Commercial and Political Atlas (1786) .center[ ] .small[Reference: https://en.wikipedia.org/wiki/William_Playfair] ??? In this section, I am going share with you five very well designed time-series data visualisation and hope they inspired you. The first data visualisation is Playfair’s Commercial and Political Atlas (1786). This is not a typical time-series line graph. As you can see, the author put in conscious effort to shade the space between the import and export curve in order to reveal time interval with trade deficit and time interval with trade surplus. --- ## A short visual history of time-series graphs ### Playfair’s Chewing at One View Chart (1821) .center[ ] .small[Reference: https://wam.fandom.com/wiki/William_Playfair%27s_Price_of_Wheat] ??? This data visualisation is also a creation of William Playfair. It is make up of two graphical methods namely bar chart and line graph. Bar chart was used to show the price trend of the quarter of wheat and line graph was used to reveal wage trends of labour by the week. --- ## A short visual history of time-series graphs ### Bump Chart shows rank of the most populous cities at each census: 1790-1890 .center[ ] .small[An interactive version here http://vallandingham.me/census_bump/] ??? This data visualisation shows rank of the most populous cities at each census 1790-1890. Instead of using lines, this data visualisation using ellipses. The more recent times were on the left of the data visualisation and the earlier times were on the right. Note that the original data visualisation was static. --- ## A short visual history of time-series graphs ### Multiple charts showing records of the Weather in New York City for December, 1912. .center[ ] ??? This data visualisation shows record of the Weather in New York City for December, 1912. The bold line indicates temperature in degrees Fahrenheit. The light solid line shows wind velocity in miles per hour. The dotted line depicts relative humidity in percentage from readings taken at 8 a.m. and 8 p.m. Arrows portray the prevailing direction of the wind. Initials at the base of the chart show the weather conditions as follows: S, clear; PC, partly cloudy; C, cloudy; R, rain; Sn, snow. --- ## Time-series graph that change public understading ### The Hockey Stick Chart .center[ ] .small[ Reference: Michael E. Mann, Raymond S. Bradley, Malcolm K. Hughes (1999) ["Northern hemisphere temperatures during the past millennium: Inferences, uncertainties, and limitations"](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/1999GL900070). *Geophysical Research Letters*, Vol. 26, No. pp. 759-762. ] ??? Hockey stick graphs present the global or hemispherical mean temperature record of the past 500 to 2000 years as shown by quantitative climate reconstructions based on climate proxy records. These reconstructions have consistently shown a slow long term cooling trend changing into relatively rapid warming in the 20th century, with the instrumental temperature record by 2000 exceeding earlier temperatures. It is a good example of how data visualisation can be used to create global awareness of rapid warming in the 20th century. --- # Time-series data patterns .vlarge[ - Trend - Variability - Rate of change - Co-variation - Cycles - Exceptions ] ??? In this section, I am going share with you time-series characteristics reveal visually. --- ## Time-series Patterns: Trend .left-column[ .large[ - The overall or general direction of change in a series of time-series values is called the trend.]] .right-column[ .center[ ]] --- ## Time-series Patterns: Trend .left-column[ .large[ - An upward trend.]] .right-column[ .center[ ]] ??? This line graph reveals an upward trend of monthly visitor arrivals from Vietnam between 2007-2018. --- ## Time-series Patterns: Trend .left-column[ .large[ - A mixed trends.]] .right-column[ .center[ ]] ??? This line graph, on the other, reveals a mixed of upward and plateau trends of monthly visitor arrivals from Malaysia between 2007-2018. --- ## Time-series Patterns: Variability .large[ - The average degree of change from one point of time to the next throughout a particular span of time.] .pull-left[ ] -- .pull-right[ ] ??? In order to show variability, we should avoid using a highly aggregated time interval like the line graph shown on the left of the slide. --- ## Time-series Patterns: Cycles .left-column[ .large[ - Cycles are patterns that repeat at regular intervals.]] .right-column[ .center[ ]] ??? From the line graph, we can see that visitor arrivals from United Kingdom reach its peak on January and lowest on May every year. --- ## Time-series Patterns: Rate of change .left-column[ .large[ - The percentage difference between one value to the next value.]] .right-column[ .center[ ]] --- ## Time-series Patters: Co-variation .left-column[ .large[ - When two time series relate to one another so that changes in one are reflected as changes in the other, either immediately or later.]] .right-column[ .center[ ]] ??? The line graphs shows that there is a 6 months lag between visitor arrivals from New Zealand and United Kingdom. This is because during the winter at the north hemisphere, the British like to travel south ward to enjoy the warm weather. On the other hand, when the weather getting cold at the south hemisphere, the New Zealanders will travel north ward to enjoy the warm weather there. --- ## Time-series Patterns: Exceptions .large[ - Values that fall outside the norm.] .center[ ] ??? This line graph show the significant impact of SAR on the visitor arrivals pattern to Singapore. --- ## Line graph design tips ### Not all line graphs should start at zero! .pull-left[  ] -- .pull-right[  ] ??? In this section, I am going to share with you some tips when we want to visualise time-series data. This slide shows that by keeping the y-axis starts at zero might not be able to reveal time-series patterns or trends effectivelly. Hence, it is important to customise the y-axis in search a way that it can reveal the time-series patterns effectively like the line graph on the right of the slide. --- ## Line graph design tips ### Multiple lines in a single graph is less effective than trellis line graph .pull-left[  ] -- .pull-right[  ] ??? In order to support effective comparison, sometime trellis line graphs are more functional then a composite line graph as shown on the right of the slide. --- ## Line graph design tips ### Not all time-series graphs have time on the x-axis .center[  ] .small[ Source: https://ourworldindata.org/growth-and-structural-transformation-are-emerging-economies-industrializing-too-quickly ] ??? The **connected scatter plot** below reveals changes over time by joining each time event points on the scatter plot. The historical trail can be a effective alternative to animation. --- ## Line graph design tips ### Label line graph instead of using legend .pull-left[  ] -- .pull-right[  ] ??? When ever possible, it is more effective to label on the line directly as shown on the line graph on the right instead of using legend. --- ## Line graph design tips .pull-left[ ### Line chart without reference line ] -- .pull-right[ ### Line chart with reference line ] ??? In order to support comparison over time effectively, reference line should be used. --- ## Line graph design tips ### Line chart with reference band .center[ ] ??? The reference used don't have to confine a single line. A confidence interval or quantile range can be used too. --- ## Beyond Line Graph ### Control Chart: An analytical line chart .center[ ] ??? Control charts, also known as Shewhart charts (after Walter A. Shewhart) or process-behavior charts. They are a statistical process control tool used to determine if a manufacturing or business process is in a state of control. Beside the average line, there are two additional lines namely the upper control limit (UCL) and lower control limit (LCL). Any data points located beyond UCL or LCL will be flag out as anomalies. --- ### Control chart in real world .center[ ] ??? In this use-case, control chart was used to display numbers of views of a digital news platform. Notice that two sets of reference lines were used. One for 5 and 95 percentile and upper and lower quantile. --- ## Beyond Line Graph ### Candlestick chart .center[ ] ??? Candlestick Charts display multiple bits of price information such as the open price, close price, highest price and lowest price through the use of candlestick-like symbols. --- ### Candlestick chart #### Interpreting candlestick chart .center[ ] ??? Candlesticks are usually composed of the body (black or white), and an upper and a lower shadow (wick): the area between the open and the close is called the real body, price excursions above and below the real body are called shadows. The wick illustrates the highest and lowest traded prices of a security during the time interval represented. The body illustrates the opening and closing trades. If the security closed higher than it opened, the body is white or unfilled, with the opening price at the bottom of the body and the closing price at the top. If the security closed lower than it opened, the body is black, with the opening price at the top and the closing price at the bottom. A candlestick need not have either a body or a wick. --- ### Candlestick chart #### Interpreting candlestick chart .center[ ] ??? To better highlight price movements, modern candlestick charts (especially those displayed digitally) often replace the black or white of the candlestick body with colors such as red (for a lower closing) and blue or green (for a higher closing). In some East Asian countries such as Taiwan, China, Japan, and South Korea, the colouring scheme is reversed (red for higher closing, and green/blue for a lower closing). --- ### Learning from the Master This link provides an example of [interactive candlestick](https://public.tableau.com/profile/stanke#!/vizhome/WorkoutWednesday-Week13CanyoucreateadynamicviewofhistoricalDATAstockpricesWorkoutWednesday2019/WorkoutWednesday2019-Week13?:embed=yes&:display_count=yes&:toolbar=no). .center[  ] Click on this [link](http://www.workout-wednesday.com/2019-week-13/) for more detail. --- ## Challenge I: Visualising Change between Two Points in Time ### Bar chart method .center[ ] --- ## Slopegraphs come to rescue! .center[  ] .small[Reference: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk] ??? Slopegraphs compare changes usually over time for a list of nouns located on an ordinal or interval scale. --- ### Learning from the Master Visit [Tableau Public](https://public.tableau.com/views/Slopegraphs/Slopegraphs?%3Aembed=y&%3AshowVizHome=no&%3Adisplay_count=y&%3Adisplay_static_image=y&%3AbootstrapWhenNotified=true&%3Alanguage=en&%3Amobile=true&:embed=y&:showVizHome=n&:apiID=host0) to try out the interactive version and visit this [link](https://dataremixed.com/2013/12/slopegraphs-in-tableau/) to learn more. .center[  ] --- ## Challenge II: Visualising cyclical patterns ### Classic line graph method .center[ ] --- ## Challenge II: Visualising cyclical patterns ### Solution: Cycle plot .center[ ] .small[Reference: http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf] --- ## Challenge II: Visualising cyclical patterns ### Solution: Sunburst diagram method .center[ ] --- ## Challenge III: Massive Time-series Data ### Classic line graph method .center[ ] ??? Line graph will not be effective to reveal high number of time series lines (for example 50) --- ## Challenge III: Massive Time-series Data ### Solution: Horizon graph .center[  ] .small[Reference: https://www.perceptualedge.com/articles/visual_business_intelligence/time_on_the_horizon.pdf] ??? By dividing an area chart into consecutive layers, horizon graphs present time-series data in a compact space while preserving resolution. --- ## Solution: Horizon graph ### The basic construct of a horizon graph .left-column[ .large[Figure on the right shows the process of constructing an horizon graph.] .small[Reference: [The Developmentof the Horizon Graph](http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=3556C47AD33B1577060EEA3F409ECD32?doi=10.1.1.363.5396&rep=rep1&type=pdf)] ] .right-column[ .center[  ]] --- ### Horizon graph in Tableau .center[ ] .small[Source: https://public.tableau.com/en-us/gallery/unemployment-horizon-chart]. .small[This video https://www.tableau.com/learn/tutorials/on-demand/horizon-charts provides step-by-step explanation on how to create a horizon graph using Tableau]. --- ## Challenge IV: Distribution over time .pull-left[ ### Line graph method .center[  ]] -- .pull-right[ ### Boxplot method .center[  ]] --- ## Alternative Time-series Data Visualisation methods ### Calendar Heatmap .center[  ] .small[Source: http://mbostock.github.io/d3/talk/20111018/calendar.html] ??? It is a 2-dimensional calendar view that shows a value over time through color coding it, often with warmer colors indicating higher values (hence heatmap). --- ## Alternative Time-series Data Visualisation methods ### Stream Graph (also know as ThemeRiver) .center[ ] .small[Reference: https://datavizcatalogue.com/methods/stream_graph.html]] ??? A streamgraph, or stream graph, is a type of stacked area graph which is displaced around a central axis, resulting in a flowing, organic shape. --- ## Visualising Change Over Time ### Animated bubble plot (or motion chart) .center[  ] ??? A motion chart displays changes over time by showing movement within the two-dimensional space and changes in the size and color of the bubbles. --- ## References Claus. O. Wilke (2019) **Fundamentals of Data Visualisation**, O’Reilly. USA. [Chapter 13 Visualizing time series and other functions of an independent variable](https://clauswilke.com/dataviz/time-series.html) and [Chapter 14 Visualizing trends](https://clauswilke.com/dataviz/visualizing-trends.html) [Introduction to Cycle Plots](http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf) [Slopegraphs for comparing gradients: Slopegraph theory and practice](http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk) [The Development of the Horizon Graph](http://www.stonesc.com/Vis08_Workshop/DVD/Reijner_submission.pdf)