Us unemployment

URL: http://bokeh.pydata.org/en/latest/docs/gallery/unemployment.html

Most examples work across multiple plotting backends, this example is also available for:

In [1]:
import pandas as pd
import holoviews as hv
hv.extension('matplotlib')

Defining data

In [2]:
from bokeh.sampledata.unemployment1948 import data

colors = ["#75968f", "#a5bab7", "#c9d9d3", "#e2e2e2", "#dfccce", "#ddb7b1", "#cc7878", "#933b41", "#550b1d"]

data = pd.melt(data.drop('Annual', 1), id_vars='Year', var_name='Month', value_name='Unemployment')

heatmap = hv.HeatMap(data, label="US Unemployment (1948 - 2013)")

Plot

In [3]:
from matplotlib.colors import ListedColormap

plot_opts = dict(fig_size=450, show_values=False, aspect=3, labelled=[], xrotation=45)
style = dict(cmap=ListedColormap(colors))

heatmap(plot=plot_opts, style=style)
Out[3]:

Download this notebook from GitHub (right-click to download).