Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Interactive Tools of Plots in HoloViews

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

import numpy as np
import pandas as pd
import holoviews as hv

hv.extension("bokeh")
Loading...
Loading...
Loading...
%%opts Points [size_index='z' width=600, height=500 tools=['hover']] HeatMap [toolbar='above' tools=['hover']]
points = hv.Points([(chr(i+65), chr(j+65), i*j) for i in range(10) for j in range(10)], vdims='z')
hv.HeatMap(points) * points
Loading...
macro_df = pd.read_csv("http://assets.holoviews.org/macro.csv", "\t")
key_dimensions = [("year", "Year"), ("country", "Country")]
value_dimensions = [
    ("unem", "Unemployment"),
    ("capmob", "Capital Mobility"),
    ("gdp", "GDP Growth"),
    ("trade", "Trade"),
]
macro = hv.Table(macro_df, key_dimensions, value_dimensions)
%%opts Overlay [width=700 height=400 show_frame=False]
%%opts Curve [tools=['hover']] Scatter [color_index=2 size_index=2 scaling_factor=1.4] (cmap='Blues' line_color='k')
%%opts VLine (color='k' line_width=1)
%%opts Text (text_font_size='13px')
gdp_curves = macro.to.curve("Year", "GDP Growth")
gdp_unem_scatter = macro.to.scatter("Year", ["GDP Growth", "Unemployment"])
annotations = (
    hv.Arrow(1973, 8, "Oil Crisis", "v")
    * hv.Arrow(1975, 6, "Stagflation", "v")
    * hv.Arrow(1979, 8, "Energy Crisis", "v")
    * hv.Arrow(1981.9, 5, "Early Eighties\n Recession", "v")
)
gdp_curves * gdp_unem_scatter * annotations
Loading...