f,a = plt.subplots(nrows=5, ncols=2, figsize=(14, 20))
a = a.ravel()
for idx,ax in enumerate(a):
v_list = km_center[idx]
df_timeband_meanrate = pd.DataFrame(
{
'timeband': name_list,
'rate': v_list
},
)
print(idx, np.bincount(y_km)[idx])
display(df_timeband_meanrate)
ax.pie(df_timeband_meanrate["rate"], labels=['' for i in range(8)],autopct='%.2f %%')
ax.set_title('cluster: {}, number: {}'.format(idx, np.bincount(y_km)[idx]))
ax.legend(loc="upper left", bbox_to_anchor=(0.85,1.025), labels=df_timeband_meanrate["timeband"])
plt.tight_layout( )
plt.savefig('time_cluster_center.png', dpi=100)
plt.show()
matplotlib.org
stackoverflow.com
stackoverflow.com
qiita.com