NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/proc2plot/trunk/proc2plot/scratch/legend_scatter.py

Revision 329 (checked in by haines, 14 years ago)

import first verison proc2plot

  • Property svn:executable set to
Line 
1 #!/usr/bin/env python
2 from pylab import *
3 import os
4
5 N=100
6
7 props = dict( alpha=0.5, faceted=False )
8
9 handles = []
10 colours = ['red', 'green', 'blue', 'magenta', 'cyan', 'yellow']
11 colours = ['red', 'green', 'blue']
12 for colour in colours:
13     x, y = rand(2,N)
14     s = 400.0 * rand(N)
15     handles.append(scatter(x, y, c=colour, s=s, **props))
16    
17 legend(handles, colours)
18 grid(True)
19
20 leg = gca().get_legend()
21 ltext  = leg.get_texts()  # all the text.Text instance in the legend
22 llines = leg.get_lines()  # all the lines.Line2D instance in the legend
23 frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
24
25 # see text.Text, lines.Line2D, and patches.Rectangle for more info on
26 # the settable properties of lines, text, and rectangles
27 frame.set_facecolor('0.80')      # set the frame face color to light gray
28 setp(ltext, fontsize='small')    # the legend text fontsize
29 setp(llines, linewidth=1.5)      # the legend linewidth
30 #leg.draw_frame(False)           # don't draw the legend frame
31
32 #show()
33 savefig('legend_scatter.png')
34 os.system('ls *.png')
35 os.system('scp -r *.png haines@pitot.marine.unc.edu:/afs/isis.unc.edu/depts/marine/workspace/haines/public_html/nccoos/test')
36
37
38                
Note: See TracBrowser for help on using the browser.