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

root/proc2plot/trunk/proc2plot/spin/spin_crow_all_plot_month.py

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

import first verison proc2plot

  • Property svn:executable set to
Line 
1 #!/usr/bin/env /opt/env/haines/dataproc/bin/python
2 # Last modified:  Time-stamp: <2010-04-05 11:59:42 haines>
3 """crow_all_plot_month"""
4
5 import os, sys, glob, re
6 import datetime, time, dateutil, dateutil.tz
7 import pycdf
8 import numpy
9
10 sys.path.append('/opt/env/haines/dataproc/raw2proc')
11 del(sys)
12
13 os.environ["MPLCONFIGDIR"]="/home/haines/.matplotlib/"
14
15 from pylab import figure, twinx, savefig, setp, getp, cm, colorbar
16 from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, DateFormatter, date2num, num2date
17 import procutil
18
19 print 'crow_all_plot_month ...'
20
21 proc_dir = '/seacoos/data/nccoos/level1/crow/wq/'
22 # fns = glob.glob((os.path.join(proc_dir, '*.nc')))
23 fns = glob.glob((os.path.join(proc_dir, '*2009_1?*.nc')))
24 fns.sort()
25
26 for fn in fns:
27     m=re.search('\d{4}_\d{2}', fn)
28     yyyy_mm = m.group()
29     prev_month, this_month, next_month = procutil.find_months(yyyy_mm)
30     yyyy_mm_str = this_month.strftime('%Y_%m')
31    
32     # load data
33     print ' ... ... read: ' + fn
34     nc = pycdf.CDFMF((fn,))
35     ncvars = nc.variables()
36     # print ncvars
37     es = nc.var('time')[:]
38     units = nc.var('time').units
39     dt = [procutil.es2dt(e) for e in es]
40     # set timezone info to UTC (since data from level1 should be in UTC!!)
41     dt = [e.replace(tzinfo=dateutil.tz.tzutc()) for e in dt]
42     # return new datetime based on computer local
43     dt_local = [e.astimezone(dateutil.tz.tzlocal()) for e in dt]
44     dn = date2num(dt)
45    
46     z = nc.var('z')[:]
47     wtemp = nc.var('wtemp')[:]
48     cond = nc.var('cond')[:]
49     turb = nc.var('turb')[:]
50     ph = nc.var('ph')[:]
51     do_mg = nc.var('do_mg')[:]
52     do_sat = nc.var('do_sat')[:]
53     batt = nc.var('battvolts')[:]
54     nc.close()
55
56     fn_flow = '/seacoos/data/nccoos/level1/crow/flow/crow_flow_' + yyyy_mm_str + '.nc'
57     print ' ... ... read: ' + fn_flow
58     nc = pycdf.CDFMF((fn_flow,))
59     ncvars = nc.variables()
60     # print ncvars
61     es2 = nc.var('time')[:]
62     units = nc.var('time').units
63     dt2 = [procutil.es2dt(e) for e in es2]
64     # set timezone info to UTC (since data from level1 should be in UTC!!)
65     dt2 = [e.replace(tzinfo=dateutil.tz.tzutc()) for e in dt2]
66     dn2 = date2num(dt2)
67    
68     r2 = nc.var('rain')[:] # inches of rain in past 15 min
69     have_sontek = 'sontek_wl' in ncvars.keys() or 'sontek_flow' in ncvars.keys()
70     have_press = 'press_wl' in ncvars.keys() or 'press_flow' in ncvars.keys()
71    
72     if have_press:
73         pwl2 = nc.var('press_wl')[:] # feet
74         pfl2 = nc.var('press_flow')[:] # cfs
75    
76     if have_sontek:
77         swl2 = nc.var('sontek_wl')[:] # feet
78         sfl2 = nc.var('sontek_flow')[:] # cfs
79    
80     nc.close()
81
82     # last dt in data for labels
83     dtu = dt[-1]
84     dtl = dt_local[-1]
85    
86     diff = abs(dtu - dtl)
87     if diff.days>0:
88         last_dt_str = dtu.strftime("%H:%M %Z on %b %d, %Y") + ' (' + dtl.strftime("%H:%M %Z, %b %d") + ')'
89     else:
90         last_dt_str = dtu.strftime("%H:%M %Z") + ' (' + dtl.strftime("%H:%M %Z") + ')' \
91                       + dtl.strftime(" on %b %d, %Y")
92        
93     #######################################
94     # Plot month all wq (plus flow) the timeseries data
95     #######################################
96
97     fig = figure(figsize=(10, 9))
98     fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9, wspace=0.1, hspace=0.1)
99    
100     ax = fig.add_subplot(6,1,1)
101     axs = [ax]
102    
103     # ax.plot returns a list of lines, so unpack tuple
104     (x, y) = procutil.addnan(dt, wtemp)
105     ibad = y <= -6999.
106     y[ibad] = numpy.nan
107     # if all are NaN's then pyplot throws an error for autoscale
108     # for some reason setting one value in the timeseries to a real value
109     # fixes this.
110     if numpy.isnan(y).all():
111         y[-1]=0.
112        
113     l1, = ax.plot_date(x, y, fmt='b-')
114     l1.set_label('Water Temperature')
115    
116     ax.set_ylabel('TEMP\n (deg C)')
117     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
118     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
119     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
120     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
121     ax.set_xticklabels([])
122
123     # right-hand side scale
124     ax2 = twinx(ax)
125     ax2.yaxis.tick_right()
126     # convert (lhs) deg C to (rhs) deg F
127     f = [procutil.celsius2fahrenheit(val) for val in ax.get_ylim()]
128     ax2.set_ylim(f)
129     ax2.set_ylabel('(deg F)')
130
131     ax2.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
132     ax2.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
133     ax2.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
134     ax2.set_xticklabels([])
135
136     # this only moves the label not the tick labels
137     ax.xaxis.set_label_position('top')
138     ax.set_xlabel('CROW Water Quality -- ' + yyyy_mm_str)
139    
140     # legend
141     ls1 = l1.get_label()
142     leg = ax.legend((l1,), (ls1,), loc='upper left')
143     ltext  = leg.get_texts()  # all the text.Text instance in the legend
144     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
145     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
146     frame.set_facecolor('0.80')      # set the frame face color to light gray
147     frame.set_alpha(0.5)             # set alpha low to see through
148     setp(ltext, fontsize='small')    # the legend text fontsize
149     setp(llines, linewidth=1.5)      # the legend linewidth
150     # leg.draw_frame(False)           # don't draw the legend frame
151    
152     #######################################
153     #
154     ax = fig.add_subplot(6,1,2)
155     axs.append(ax)
156
157     # ax.plot returns a list of lines, so unpack tuple
158     (x, y) = procutil.addnan(dt, cond)
159     l1, = ax.plot_date(x, y, fmt='b-')
160     l1.set_label('Specific Conductivity')
161    
162     ax.set_ylabel('Cond\n (mS/cm)')
163     # ax.set_ylim(0,10)
164     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
165     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
166     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
167     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
168     ax.set_xticklabels([])
169
170     # legend
171     ls1 = l1.get_label()
172     leg = ax.legend((l1,), (ls1,), loc='upper left')
173     ltext  = leg.get_texts()  # all the text.Text instance in the legend
174     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
175     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
176     frame.set_facecolor('0.80')      # set the frame face color to light gray
177     frame.set_alpha(0.5)             # set alpha low to see through
178     setp(ltext, fontsize='small')    # the legend text fontsize
179     setp(llines, linewidth=1.5)      # the legend linewidth
180     # leg.draw_frame(False)           # don't draw the legend frame
181    
182     #######################################
183     #
184     ax = fig.add_subplot(6,1,3)
185     axs.append(ax)
186        
187     # ax.plot returns a list of lines, so unpack tuple
188     (x, y) = procutil.addnan(dt, do_mg)
189     l1, = ax.plot_date(x, y, fmt='b-')
190     l1.set_label('Dissolved Oxygen (DO)')
191    
192     ax.set_ylabel('DO \n(mg/l)')
193     # ax.set_ylim(20,120)
194     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
195     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
196     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
197     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
198     ax.set_xticklabels([])
199
200     # right-hand side scale
201     ax2 = twinx(ax)
202     ax2.yaxis.tick_right()
203     (x, y) = procutil.addnan(dt, do_sat)
204     l2, = ax2.plot_date(x, y, fmt='c-')
205     l2.set_label('Percent Air Saturation')   
206     # convert (lhs) deg C to (rhs) deg F
207     # ax2.set_ylim(0,200)
208     ax2.set_ylabel('DO (%)')
209     ax2.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
210     ax2.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
211     ax2.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
212     ax2.set_xticklabels([])
213    
214     # legend
215     ls1 = l1.get_label()
216     ls2 = l2.get_label()
217     leg = ax.legend((l1,l2), (ls1,ls2), loc='upper left')
218     ltext  = leg.get_texts()  # all the text.Text instance in the legend
219     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
220     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
221     frame.set_facecolor('0.80')      # set the frame face color to light gray
222     frame.set_alpha(0.5)             # set alpha low to see through
223     setp(ltext, fontsize='small')    # the legend text fontsize
224     setp(llines, linewidth=1.5)      # the legend linewidth
225     # leg.draw_frame(False)           # don't draw the legend frame
226     #######################################
227     #
228     ax = fig.add_subplot(6,1,4)
229     axs.append(ax)
230
231     # ax.plot returns a list of lines, so unpack tuple
232     (x, y) = procutil.addnan(dt, ph)
233     l1, = ax.plot_date(x, y, fmt='b-')
234     l1.set_label('pH')
235    
236     ax.set_ylabel('pH')
237     # ax.set_ylim(6, 12)
238     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
239     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
240     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
241     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
242     ax.set_xticklabels([])
243
244     # legend
245     ls1 = l1.get_label()
246     leg = ax.legend((l1,), (ls1,), loc='upper left')
247     ltext  = leg.get_texts()  # all the text.Text instance in the legend
248     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
249     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
250     frame.set_facecolor('0.80')      # set the frame face color to light gray
251     frame.set_alpha(0.5)             # set alpha low to see through
252     setp(ltext, fontsize='small')    # the legend text fontsize
253     setp(llines, linewidth=1.5)      # the legend linewidth
254     # leg.draw_frame(False)           # don't draw the legend frame
255    
256     #######################################
257     #
258     ax = fig.add_subplot(6,1,5)
259     axs.append(ax)
260    
261     # ax.plot returns a list of lines, so unpack tuple
262     (x, y) = procutil.addnan(dt, turb)
263     l1, = ax.plot_date(x, y, fmt='b-')
264     l1.set_label('Turbidity')
265    
266     ax.set_ylabel('Turb \n(NTU)')
267     # ax.set_ylim(0,100)
268     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
269     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
270     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
271     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
272     ax.set_xticklabels([])
273
274     # legend
275     ls1 = l1.get_label()
276     leg = ax.legend((l1,), (ls1,), loc='upper left')
277     ltext  = leg.get_texts()  # all the text.Text instance in the legend
278     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
279     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
280     frame.set_facecolor('0.80')      # set the frame face color to light gray
281     frame.set_alpha(0.5)             # set alpha low to see through
282     setp(ltext, fontsize='small')    # the legend text fontsize
283     setp(llines, linewidth=1.5)      # the legend linewidth
284     # leg.draw_frame(False)           # don't draw the legend frame
285    
286     #######################################
287     #
288     ax = fig.add_subplot(6,1,6)
289     axs.append(ax)
290    
291     # ax.plot returns a list of lines, so unpack tuple
292     if have_press:
293         (x, y) = procutil.addnan(dt2, pfl2)
294         l1, = ax.plot_date(x, y, fmt='b-')
295         l1.set_label('Derived from pressure')
296         ls1 = l1.get_label()
297     if have_sontek:
298         (x, y) = procutil.addnan(dt2, sfl2)
299         l2, = ax.plot_date(x, y, fmt='c-')
300         l2.set_label('Depth-avg Acoustic Profile')   
301         ls2 = l2.get_label()
302    
303     ax.set_ylabel('Flow\n (cfs)')
304     # ax.set_ylim(0,15)
305     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
306     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
307     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
308     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
309
310     ax.set_xlabel('CROW Water Quality -- ' + yyyy_mm_str)
311
312     # legend
313     if have_press and have_sontek:
314         leg = ax.legend((l1,l2), (ls1,ls2), loc='upper left')
315     elif have_press:
316         leg = ax.legend((l1,), (ls1,), loc='upper left')       
317     if have_sontek:
318         leg = ax.legend((l2,), (ls2,), loc='upper left')       
319
320     ltext  = leg.get_texts()  # all the text.Text instance in the legend
321     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
322     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
323     frame.set_facecolor('0.80')      # set the frame face color to light gray
324     frame.set_alpha(0.5)             # set alpha low to see through
325     setp(ltext, fontsize='small')    # the legend text fontsize
326     setp(llines, linewidth=1.5)      # the legend linewidth
327     # leg.draw_frame(False)           # don't draw the legend frame
328
329     # save figure   
330     ofn = '/home/haines/rayleigh/img/crow/crow_wq_'+yyyy_mm_str+'.png'
331     print '... ... write: %s' % (ofn,)
332     savefig(ofn)
333
334     del(fig)
335        
336     #######################################
337     # Plot month all rain flow the timeseries data
338     #######################################
339
340     fig = figure(figsize=(10, 8))
341     fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9, wspace=0.1, hspace=0.1)
342    
343     ax = fig.add_subplot(4,1,1)
344     axs = [ax]
345    
346     # ax.plot returns a list of lines, so unpack tuple
347     (x, y) = procutil.addnan(dt2, r2)
348     l1, = ax.plot_date(x, y, fmt='b-')
349     l1.set_label('Precipitation')
350    
351     ax.set_ylabel('Rain (in)')
352     # ax.set_ylim(0,30)
353     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
354     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
355     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
356     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
357     ax.set_xticklabels([])
358
359     # right-hand side scale
360     ax2 = twinx(ax)
361     ax2.yaxis.tick_right()
362     # convert (lhs) deg C to (rhs) deg F
363     f = [procutil.inches2millimeters(val) for val in ax.get_ylim()]
364     ax2.set_ylim(f)
365     ax2.set_ylabel('Rain (mm)')
366     ax2.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
367     ax2.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
368     ax2.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
369     ax2.set_xticklabels([])
370
371     # this only moves the label not the tick labels
372     ax.xaxis.set_label_position('top')
373     ax.set_xlabel('CROW Stream Flow -- ' + yyyy_mm_str)
374    
375     # legend
376     ls1 = l1.get_label()
377     leg = ax.legend((l1,), (ls1,), loc='upper left')
378     ltext  = leg.get_texts()  # all the text.Text instance in the legend
379     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
380     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
381     frame.set_facecolor('0.80')      # set the frame face color to light gray
382     frame.set_alpha(0.5)             # set alpha low to see through
383     setp(ltext, fontsize='small')    # the legend text fontsize
384     setp(llines, linewidth=1.5)      # the legend linewidth
385     # leg.draw_frame(False)           # don't draw the legend frame
386    
387     #######################################
388     #
389     ax = fig.add_subplot(4,1,2)
390     axs.append(ax)
391
392     # ax.plot returns a list of lines, so unpack tuple
393     if have_press:
394         (x, y) = procutil.addnan(dt2, pwl2)
395         l1, = ax.plot_date(x, y, fmt='b-')
396         l1.set_label('Derived from pressure')
397         ls1 = l1.get_label()
398     if have_sontek:
399         (x, y) = procutil.addnan(dt2, swl2)
400         l2, = ax.plot_date(x, y, fmt='c-')
401         l2.set_label('From Acoustic Sounding')   
402         ls2 = l2.get_label()
403    
404     ax.set_ylabel('Depth (ft)')
405     # ax.set_ylim(0,15)
406     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
407     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
408     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
409     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
410     ax.set_xticklabels([])
411
412     # right-hand side scale
413     ax2 = twinx(ax)
414     ax2.yaxis.tick_right()
415     # convert (lhs) feet to (rhs) meters
416     f = [procutil.feet2meters(val) for val in ax.get_ylim()]
417     ax2.set_ylim(f)
418     ax2.set_ylabel('Depth (m)')
419     ax2.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
420     ax2.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
421     ax2.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
422     ax2.set_xticklabels([])
423
424     # legend
425     if have_press and have_sontek:
426         leg = ax.legend((l1,l2), (ls1,ls2), loc='upper left')
427     elif have_press:
428         leg = ax.legend((l1,), (ls1,), loc='upper left')
429     elif have_sontek:
430         leg = ax.legend((l2,), (ls2,), loc='upper left')
431        
432     ltext  = leg.get_texts()  # all the text.Text instance in the legend
433     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
434     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
435     frame.set_facecolor('0.80')      # set the frame face color to light gray
436     frame.set_alpha(0.5)             # set alpha low to see through
437     setp(ltext, fontsize='small')    # the legend text fontsize
438     setp(llines, linewidth=1.5)      # the legend linewidth
439     # leg.draw_frame(False)           # don't draw the legend frame
440    
441     #######################################
442     #
443     ax = fig.add_subplot(4,1,3)
444     axs.append(ax)
445    
446     # ax.plot returns a list of lines, so unpack tuple
447     if have_press:
448         (x, y) = procutil.addnan(dt2, pfl2)
449         l1, = ax.plot_date(x, y, fmt='b-')
450         l1.set_label('Derived from pressure')
451         ls1 = l1.get_label()
452     if have_sontek:
453         (x, y) = procutil.addnan(dt2, sfl2)
454         l2, = ax.plot_date(x, y, fmt='c-')
455         l2.set_label('Depth-avg Acoustic Profile')   
456         ls2 = l2.get_label()
457    
458     ax.set_ylabel('Flow (cfs)')
459     # ax.set_ylim(0,15)
460     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
461     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
462     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
463     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
464     ax.set_xticklabels([])
465
466     # legend
467     if have_press and have_sontek:
468         leg = ax.legend((l1,l2), (ls1,ls2), loc='upper left')
469     elif have_press:
470         leg = ax.legend((l1,), (ls1,), loc='upper left')
471     elif have_sontek:
472         leg = ax.legend((l2,), (ls2,), loc='upper left')
473        
474     ltext  = leg.get_texts()  # all the text.Text instance in the legend
475     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
476     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
477     frame.set_facecolor('0.80')      # set the frame face color to light gray
478     frame.set_alpha(0.5)             # set alpha low to see through
479     setp(ltext, fontsize='small')    # the legend text fontsize
480     setp(llines, linewidth=1.5)      # the legend linewidth
481     # leg.draw_frame(False)           # don't draw the legend frame
482
483     #######################################
484     #
485     ax = fig.add_subplot(4,1,4)
486     axs.append(ax)
487
488     # ax.plot returns a list of lines, so unpack tuple
489     (x, y) = procutil.addnan(dt, batt)
490     l1, = ax.plot_date(x, y, fmt='b-')
491     l1.set_label('Station Battery')
492    
493     ax.set_ylabel('Battery\n (volts)')
494     # ax.set_ylim(6, 12)
495     ax.set_xlim(date2num(this_month), date2num(next_month-datetime.timedelta(seconds=1)))
496     ax.xaxis.set_major_locator( DayLocator(range(2,32,2)) )
497     ax.xaxis.set_minor_locator( HourLocator(range(0,25,12)) )
498     ax.xaxis.set_major_formatter( DateFormatter('%m/%d') )
499
500     ax.set_xlabel('CROW Stream Flow -- ' + yyyy_mm_str)
501
502     # legend
503     ls1 = l1.get_label()
504     leg = ax.legend((l1,), (ls1,), loc='upper left')
505     ltext  = leg.get_texts()  # all the text.Text instance in the legend
506     llines = leg.get_lines()  # all the lines.Line2D instance in the legend
507     frame  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend
508     frame.set_facecolor('0.80')      # set the frame face color to light gray
509     frame.set_alpha(0.5)             # set alpha low to see through
510     setp(ltext, fontsize='small')    # the legend text fontsize
511     setp(llines, linewidth=1.5)      # the legend linewidth
512     # leg.draw_frame(False)           # don't draw the legend frame
513    
514     # save figure   
515     ofn = '/home/haines/rayleigh/img/crow/crow_flow_' + yyyy_mm_str + '.png'
516     print '... ... write: %s' % (ofn,)
517     savefig(ofn)
518
Note: See TracBrowser for help on using the browser.