# Legend Generator # Created by Jason Godwin (21 February 2012) # # Acknowledgements: # # simpleSVG library courtesy of Brian Fiedler # # Links: # # simpleSVG: http://mensch.org/simpleSVG/ # # Contact information: # # Email: jwgodwin@ou.edu # Website: http://www.jasonsweathercenter.com # # Instructions # # This program is probably not as efficient as I would like, but is relatively # straightforward. First edit the legend labels then set the color levels. If # you change the number of colors being used, you may need to edit a few values # in the legend generator section. import simpleSVG b=simpleSVG.svg_class(fname="legend.svg",bbx=920,bby=610) # open file for your task # create color bar y = 10 # sets the vertical spacing between labels basevalue = 1000 # largest labeled value # SET LEGEND LABELS values = ["more than 1,000,000", "750,000-1,000,000", "500,000-750,000", "250,000-500,000", "100,000-250,000", "50,000-100,000", "25,000-50,000", "10,000-25,000", "less than 10,000"] level = values[0] # SET COLORS colors = ["#FFFFCC", "#FFEDA0", "#FED976", "#FEB24C", "#FD8D3C", "#FC4E2A", "#E31A1C", "#BD0026", "#800026"] # color table to use # LEGEND GENERATOR for color in range(len(colors)): x = 625 y = y + 31 b.rect(x,y,30,30,fill=colors[-color-1]) b.text(x+50,y+25,0,str(level),font_size="14pt",fill='black',text_anchor="left") if color < 8: level = values[color+1] #### end task code b.close()