Route chord

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

In [1]:
import numpy as np
import pandas as pd
import holoviews as hv
from bokeh.sampledata.airport_routes import routes, airports

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

Declare data

In [2]:
# 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

In [3]:
%%opts Chord [edge_color_index='SourceID' label_index='City' color_index='AirportID']
%%opts Chord (cmap='Category20' edge_cmap='Category20')
busiest_airports
Out[3]: