Route Chord#

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


Most examples work across multiple plotting backends. This example is also available for:

import holoviews as hv

from holoviews import dim
from bokeh.sampledata.airport_routes import routes, airports

hv.extension('matplotlib')
hv.output(fig='svg', size=300)

Declare data#

# Count the routes between Airports
route_counts = routes.groupby(['SourceID', 'DestinationID']).Stops.count().reset_index()
nodes = hv.Dataset(airports, 'AirportID', 'City')
chord = hv.Chord((route_counts, nodes), ['SourceID', 'DestinationID'], ['Stops'])

# Select the 20 busiest airports
busiest = list(routes.groupby('SourceID').count().sort_values('Stops').iloc[-20:].index.values)
busiest_airports = chord.select(AirportID=busiest, selection_mode='nodes')

Plot#

busiest_airports.opts(
    cmap='Category20', labels='City',
    edge_color=dim('SourceID').astype(str),
    node_color=dim('AirportID').astype(str))
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

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