This notebook was created to map CAIDA Users and ASes by country. Current size is a world map.
The notebook using Geopandas and Geoplot. This means that you will need to set up a virtual environment. Personally, I used this Medium article by Tanish Gupta to set up my environment.
To run the notebook:
- Activate conda virtual env that has Geopandas by running the following command in Anaconda Prompt
conda activate yourenv
- Launch notebook menu using:
jupyter notebook
- Navigate to notebook and run
When using the Geopandas package, the documentation does not discuss multivariate maps. However, you can use base maps then plot on top of them. In the below example, a choropleth map is plotted first in ax
. Then, a point plot is plotted on top of the ax
.
scheme_one = mc.FisherJenks(merged['num_users'], k=7)
ax = gplt.choropleth(
merged,
hue='num_users',
scheme=scheme_one,
cmap='Blues',
legend=True,
figsize=(18,14)
)
gplt.pointplot(
merged_centroids,
ax=ax,
scale='num_ASes',
color='red',
legend=True,
limits=(3, 30),
legend_values=[400, 200, 100, 50, 25, 10],
legend_labels=['≤ 400 ASes', '≤ 200 ASes', '≤ 100 ASes', '≤ 50 ASes', '≤ 25 ASes', '≤ 10 ASes']
)
Since, Geopandas is built on top of Matplotlib, you can utilize underlying Matplotlib functions for legends an plots.
plt.title("ASes and Users by Country")
ax.get_legend().set_title("Users")
plt.savefig('ases_and_users_by_country.png')