In [1]:
import sankey
import matplotlib.pyplot as plt
%matplotlib inline
import pandas as pd
pd.options.display.max_rows=8

In [2]:
df = pd.read_csv('./fruits.txt',sep = ' ',names=['true','predicted'])

In [3]:
df


Out[3]:
true predicted
0 blueberry blueberry
1 apple blueberry
2 blueberry blueberry
3 lime lime
... ... ...
996 blueberry blueberry
997 apple apple
998 apple banana
999 orange orange

1000 rows × 2 columns


In [4]:
colorDict =  {'apple':'#f71b1b','blueberry':'#1b7ef7','banana':'#f3f71b','lime':'#12e23f','orange':'#f78c1b'}

In [5]:
sankey.sankey(df['true'],df['predicted'],aspect=20,colorDict=colorDict,fontsize=10)
plt.gcf().set_size_inches(6,6)
plt.savefig('fruits.png',bbox_inches='tight',dpi=150)



In [ ]: