Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show every class map? #4

Closed
Aaron1993 opened this issue Jul 18, 2019 · 1 comment
Closed

How to show every class map? #4

Aaron1993 opened this issue Jul 18, 2019 · 1 comment

Comments

@Aaron1993
Copy link

Hi. I want to show every class color map like the picture, how I can do it? Thanks.
image

@gokriznastic
Copy link
Owner

gokriznastic commented Jul 19, 2019

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants