绘制 柱状图
ap_time = []
ap_time.append([n, (time.time() - t0)])
km_mat = np.array(kmeans_time)
ap_mat = np.array(ap_time)
plt.figure()
plt.bar(np.arange(3), km_mat[:, 1], width = 0.3, color = 'b', label = 'K-Means', log = 'True')
plt.bar(np.arange(3) + 0.3, ap_mat[:, 1], width = 0.3, color = 'g', label = 'AffinityPropagation', log = 'True')
plt.xlabel('Sample Number')
plt.ylabel('Computing time')
plt.title('K-Means and AffinityPropagation computing time ')
plt.legend(loc='upper center')
plt.show()