, , , , .
, LABELS range(13), (ticks) 0 12.
, , 10.6, 12!
cb.ax.set_yticklabels(map(str, LABELS)), , ( , matplotlib . map(str, LABELS)).
, , , ? - [round(tick) for tick in ticks]?
: , , ... , !:)
Edit2:
, , imshow . ( ... ?)
, , LinearSegmentedColormap. , matplotlib LinearSegmentedColormap ( matplotlib.cm.spectral).
, set_clim([0,12]) coloraxis, imshow.
.
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
with open('temp.pgm') as infile:
header, nrows, ncols = [infile.readline().strip() for _ in range(3)]
data = np.loadtxt(infile).astype(np.uint8)
cmap = mpl.cm.get_cmap('spectral', 13)
cax = plt.imshow(data, cmap, interpolation='nearest')
cax.set_clim([0,13])
cbar = plt.colorbar(cax, ticks=np.arange(0.5, 13, 1.0))
cbar.ax.set_yticklabels(range(13))
plt.show()
