学习笔记,仅供参考,有错必纠
更改图片尺寸并保存
image_path = "{}/k{}_max_time{}.jpg".format(file_path, k, max_time)
plt.figure(figsize = (9, 3))
plt.subplot(131)
plt.title('knn\'k: {}, max_times: {}, is_label_eq: {}\n n_components: {}, n_components2: {}'.format(k,
max_time, is_label_eq, n_components, n_components2))
plt.scatter(X[:, 0], X[:, 1], c = y)
plt.subplot(132)
plt.scatter(X[:, 0], X[:, 1], c = label)
plt.subplot(133)
plt.scatter(X[:, 0], X[:, 1], c = label2)
plt.savefig(image_path, bbox_inches = 'tight')