<jupyter_start><jupyter_text>Horizon GraphOriginally called "two-tone pseudo-coloring", a horizon graph increases the density of time series graphs by dividing and layering filled line charts.  Intro:  * We review [Sizing the Horizon: The Effects of Chart Size and Layering on the Grahpical Perception of Time Series Visualizations](http://www.vis.berkeley.edu/papers/horizon/2009-TimeSeries-CHI.pdf).  * We will use [this example](http://bl.ocks.org/mbostock/1483226) to illustrate these definitions:      1. Mirror      2. Offset      3. Band    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?* [Stock example](https://bost.ocks.org/mike/cubism/intro/demo-stocks.html).<jupyter_code>%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()<jupyter_output><empty_output><jupyter_text>Visual attributes  Line Chart* [Cleveland's Banking to the 45](http://www.jstor.org/stable/2288843?seq=1page_scan_tab_contents) - aspect ratio & perception.*  [Related paper on Banking to the 45](http://vis.stanford.edu/files/2006-Banking-InfoVis.pdf)  Stacked Graph* good: aggregate patterns* [Cleveland: perception of position vs length](https://www.cs.ubc.ca/~tmm/courses/cpsc533c-04-spr/readings/cleveland.pdf)  Horizon Graph CodeUsing Bokeh, we can quickly build a stacked graph example.<jupyter_code># 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'])
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)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16001376462491398, 'fraction_numerical': 0.023743977976600137, 'mean_word_length': 4.908536585365853, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '557656', 'license': 'Unlicense', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1061, 'n_words': 221, 'path': 'horizon-charts-101/horizon_charts_101.ipynb', 'repo_name': 'prakash123mayank/Data-Science-45min-Intros', 'size': '2906'}