Originally called "two-tone pseudo-coloring", a horizon graph increases the density of time series graphs by dividing and layering filled line charts.
Intro:
We will use this example to illustrate these definitions:
Outline:
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()
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)
E1: mirror vs offset (vary bands)
E2: line vs horizon
In [ ]: