Horizon Graph

Originally called "two-tone pseudo-coloring", a horizon graph increases the density of time series graphs by dividing and layering filled line charts.

Intro:

Outline:

  • Problem: creating an effective presentation of multiple time series.
  • Goal: display more charts in a fixed area.
  • Reason: viewers need to quickly and reliably spot trends.

Initial thoughts?


In [1]:
%matplotlib inline  
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from bokeh.charts import Horizon, output_file, show
from bokeh.io import output_notebook
%matplotlib inline  
output_notebook()


Loading BokehJS ...

Visual attributes

Line Chart

Stacked Graph

Horizon Graph Code

Using Bokeh, we can quickly build a stacked graph example.


In [2]:
# read in some stock data from the Yahoo Finance API
start_date = '2014'
end_date = '2017'
AAPL = pd.read_csv(
    "http://ichart.yahoo.com/table.csv?s=AAPL&a=0&b=1&c={sd}&d=0&e=1&f={ed}".format(sd=start_date,ed=end_date),
    parse_dates=['Date'])

MSFT = pd.read_csv(
    "http://ichart.yahoo.com/table.csv?s=MSFT&a=0&b=1&c={sd}&d=0&e=1&f={ed}".format(sd=start_date,ed=end_date),
    parse_dates=['Date'])

IBM = pd.read_csv(
    "http://ichart.yahoo.com/table.csv?s=IBM&a=0&b=1&c={sd}&d=0&e=1&f={ed}".format(sd=start_date,ed=end_date),
    parse_dates=['Date'])

TWTR = pd.read_csv(
    "http://ichart.yahoo.com/table.csv?s=TWTR&a=0&b=1&c={sd}&d=0&e=1&f={ed}".format(sd=start_date,ed=end_date),
    parse_dates=['Date'])
FB = pd.read_csv(
    "http://ichart.yahoo.com/table.csv?s=FB&a=0&b=1&c={sd}&d=0&e=1&f={ed}".format(sd=start_date,ed=end_date),
    parse_dates=['Date'])

In [3]:
data = dict([
    ('AAPL', AAPL['Adj Close']),
    ('Date', AAPL['Date']),
    ('FB', FB['Adj Close']),
    ('MSFT', MSFT['Adj Close']),
    #('IBM', IBM['Adj Close']), 
    ('TWTR', TWTR['Adj Close'])]
)

hp = Horizon(data, x='Date'
             , plot_width=800
             , plot_height=300,
             title="horizon plot using stock inputs")

#output_file("horizon.html")

show(hp)


Graphical Perception

Experiments

  • Estimation speed
  • Estimation accuracy

E1: mirror vs offset (vary bands)

  1. bands
  2. offset
  3. mirrior

E2: line vs horizon

  1. line chart
  2. horizon chart

Measurement

  1. Which point is larger? [pretty much everyone got this one correct]
  2. What is the absolute difference between the values at these two points?

Stat note

  • 80% trimmed mean per subject for each experiemental condition.

Issues

  • test size
  • no control for screen resolution

Results

  • 18 subjects
  • More bands, longer time
  • 2 or 3 bands, similar accuracy
  • 4 bands descreases accuracy
  • less accuracy in line chart than horizon
  • accuracy most declined for line charts and 1 band horizon charts small in size
  • accuracy seems to increase with larger charts
  • layering increases estimation time, but no difference b/t line and 1 band horizon charts

In [ ]: