python matplotlib显示sklearn里面的手写字体数据

使用matplotlib.pyplot 显示sklearn.dataset里面的图像数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from sklearn import datasets
import matplotlib.pyplot as plt
import numpy as np
dataImage = digits.data[-1].reshape((8,8))
fig, axes = plt.subplots(2, 2, figsize=(8, 8))
axes[0][0].imshow(dataImage, cmap='gray_r', interpolation='nearest')
axes[0][0].set_title('nearest')
axes[0][1].imshow(dataImage, cmap='gray_r', interpolation='bilinear')
axes[0][1].set_title('bilinear')
axes[1][0].imshow(dataImage, cmap='gray_r', interpolation='bicubic')
axes[1][0].set_title('bicubic')
axes[1][1].imshow(dataImage, cmap='gray_r', interpolation='spline16')
axes[1][1].set_title('spline16')
plt.show()

digits.jpg