How to show every class map?
Aaron1993 opened this issue · comments
Hey. I used the following code snippet to do so:
from matplotlib import patches
from spectral import spy_colors
labelDictionary= {0:'Unknown',1:'Alfalfa', 2:'Corn-notill', 3:'Corn-mintill', 4: 'Corn', 5:'Grass-pasture', 6:'Grass-trees', 7:'Grass-pasture-mowed', 8:'Hay-windrowed', 9:'Oats', 10:'Soybean-notill', 11:'Soybean-mintill', 12:'Soybean-clean', 13:'Wheat', 14:'Woods', 15:'Buildings-Grass-Trees-Drives', 16:'Stone-Steel-Towers'}
fig = plt.figure(figsize=(3,3))
ax = fig.add_subplot(111)
ax.set_position([0.1,0.1,0.5,0.8])
labelPatches = [ patches.Patch(color=spy_colors[x]/255., label=labelDictionary[x]) for x in np.unique(y) ]
leg = ax.legend(handles=labelPatches, ncol=2, loc='center left', bbox_to_anchor=(1.5, 0.5))
fig.savefig('SA_legend.pdf', bbox_extra_artists=(leg,), bbox_inches='tight')