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.

Scatter Plot Using HoloViews in Python

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...
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 Scatter [width=800 height=600 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True] 
%%opts Scatter (color=Cycle('Category20') line_color='k')
%%opts NdOverlay [legend_position='left' show_frame=False]
gdp_unem_scatter = macro.to.scatter('Year', ['GDP Growth', 'Unemployment'])
gdp_unem_scatter.overlay('Country')
Loading...