def plot_RF(rf, sample_shape):
norm = matplotlib.colors.Normalize()
norm.autoscale(rf)
rf = np.resize(rf, np.prod(sample_shape)).reshape(sample_shape)
norm_zero = min(max(norm(0.0), 0.0+1e-6), 1.0-1e-6)
cdict = {
'red' : ((0., 0., 0.), (norm_zero, 0.5, 0.5), (1., 1., 1.)),
'green': ((0., 0., 0.), (norm_zero, 0.5, 0.5), (1., 1., 1.)),
'blue' : ((0., 0., 0.), (norm_zero, 0.5, 0.5), (1., 1., 1.))
}
#generate the colormap with 1024 interpolated values
my_cmap = matplotlib.colors.LinearSegmentedColormap('my_colormap', cdict, 1024)
plt.imshow(rf, interpolation='nearest', origin='upper', cmap=my_cmap)
ax = plt.gca()
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
评论列表
文章目录