#!/usr/bin/env python # coding: utf-8 # In[1]: import os import ast import pandas data = pandas.read_csv( "data" + os.path.sep + "consonants_vowels.csv", # To ensure that tuples are read as tuples converters={"coordinates": ast.literal_eval}, ) data.head() # ## Charts # In[2]: import io import matplotlib.pyplot as plt pie_charts_data = zip(data.consonants, data.vowels) fig = plt.figure(figsize=(0.5, 0.5)) fig.patch.set_alpha(0) ax = fig.add_subplot(111) plots = [] for sizes in pie_charts_data: ax.pie(sizes, colors=("#e6194b", "#19e6b4")) buff = io.StringIO() plt.savefig(buff, format="SVG") buff.seek(0) svg = buff.read() svg = svg.replace("\n", "") plots.append(svg) plt.cla() plt.clf() plt.close() # ## Legend # In[3]: import branca legend_html = """ {% macro html(this, kwargs) %}