Search⌘ K
AI Features

Exercise: Bubble Chart and Hex Bin Chart

Explore how to represent data using bubble and hex bin charts with Python Altair. Understand techniques for encoding variables like size, opacity, and shape to visualize average latency and speed effectively. This lesson helps you apply these visualization methods to analyze network speed data across European countries.

Consider the following dataset describing the average download/upload speed in European countries from 2019 to 2022:

Python 3.10.4
import pandas as pd
df = pd.read_csv('data/average_internet_speed.csv',parse_dates=['quarter'])
print(df)

In the following terminal, represent the data through a bubble chart:

Python 3.10.4
import pandas as pd
import altair as alt
import os
df = pd.read_csv('data/average_internet_speed.csv',parse_dates=['quarter'])
# build the chart
# use mark_point() to draw the points
# encode the average upload and download speeds in the x and y channels
# encode the country using the color channel.
# highlight the color of a single country (e.g. IT), using alt.condition()
# chart = alt.Chart()df
# uncomment the following lines to show the chart
#chart.save('chart.html')
#os.system('cat chart.html')

Then, represent the dataset through a hex bin chart in the ...