climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From good...@apache.org
Subject svn commit: r1508115 - /incubator/climate/branches/RefactorInput/ocw/plotter.py
Date Mon, 29 Jul 2013 15:58:13 GMT
Author: goodman
Date: Mon Jul 29 15:58:13 2013
New Revision: 1508115

URL: http://svn.apache.org/r1508115
Log:
Fixed a few typos in parameter names

Modified:
    incubator/climate/branches/RefactorInput/ocw/plotter.py

Modified: incubator/climate/branches/RefactorInput/ocw/plotter.py
URL: http://svn.apache.org/viewvc/incubator/climate/branches/RefactorInput/ocw/plotter.py?rev=1508115&r1=1508114&r2=1508115&view=diff
==============================================================================
--- incubator/climate/branches/RefactorInput/ocw/plotter.py (original)
+++ incubator/climate/branches/RefactorInput/ocw/plotter.py Mon Jul 29 15:58:13 2013
@@ -143,7 +143,7 @@ class Plotter:
                 
                 # Arguments vary slightly depending on whether the time series
                 # is monthly or annual
-                if result.shape[2] % 12 == 0:
+                if result.shape[2] == len(mtimes):
                     ptimes = mtimes
                     label_month = True
                 else:
@@ -175,7 +175,7 @@ class Plotter:
     def make_plots(self):
         '''
         Calls the actual plotting functions, either defined in a separate module
-        (eg rcmes/toolkit/plots.py or placed directly in this one. 
+        (eg rcmes/toolkit/plots.py) or placed directly in this one. 
         '''
         if not self._plot_data:
             raise AttributeError('No compatible plotting functions found!')
@@ -273,14 +273,15 @@ def _fig_size(gridshape):
         
     return width, height
     
-def draw_taylor_diagram(data, names, refname, fname, fmt='png', ptitle='', 
-                        pos='upper right', frameon=False, radmax=1.5):
+def draw_taylor_diagram(datasets, names, refname, fname, fmt='png', 
+                        gridshape=(1,1), ptitle='', pos='center right', 
+                        frameon=True, radmax=1.5):
     '''
     Purpose::
         Draws a Taylor diagram
         
     Input::
-        data - an Nx2 array containing normalized standard deviations,
+        dataset - an Nx2 array containing normalized standard deviations,
                correlation coefficients, and names of evaluation datasets
         names - list of names for each evaluated dataset
         refname - The name of the reference dataset
@@ -294,16 +295,40 @@ def draw_taylor_diagram(data, names, ref
         radmax - an optional float to adjust the extent of the axes in terms of
                  standard deviation.
     '''
-    fig = plt.figure()
-    fig.suptitle(ptitle)            
-    dia = TaylorDiagram (1, fig=fig, rect=111, label=refname, radmax=radmax)
-    for i, (stddev, corrcoef) in enumerate(data):
-        dia.add_sample(stddev, corrcoef, marker='$%d$' % (i + 1), ms=6, label=names[i])
+    # Handle the single plot case. 
+    if datasets.ndim == 2:
+        datasets = datasets.reshape(1, *datasets.shape)
+
+    # Make sure gridshape is compatible with input data
+    nplots = datasets.shape[0]
+    gridshape = _best_grid_shape(nplots, gridshape)
     
-    legend = fig.legend(dia.samplePoints, [p.get_label() for p in dia.samplePoints], handlelength=0.,

-                        prop={'size': 10}, numpoints=1, loc=pos)
+    # Set up the figure
+    fig = plt.figure()
+    width, height = gridshape
+    width *= 6
+    height *= 6
+    fig.set_size_inches((width, height))
+    fig.dpi = 300
+    for i, data in enumerate(datasets):
+        rect = gridshape + (i + 1,)
+        dia = TaylorDiagram(1, fig=fig, rect=rect, label=refname, radmax=radmax)
+        for i, (stddev, corrcoef) in enumerate(data):
+            dia.add_sample(stddev, corrcoef, marker='$%d$' % (i + 1), ms=6, 
+                           label=names[i])
+    
+    # Add legend
+    legend = fig.legend(dia.samplePoints, 
+                        [p.get_label() for p in dia.samplePoints], 
+                        handlelength=0., prop={'size': 10}, numpoints=1, 
+                        loc=pos)
     legend.draw_frame(frameon)
-    fig.savefig('%s.%s' %(fname, fmt), bbox_inches='tight')    
+    plt.subplots_adjust(wspace=0)          
+    
+    # Add title and save the figure
+    fig.suptitle(ptitle)
+    plt.tight_layout(.05, .05)
+    fig.savefig('%s.%s' %(fname, fmt), bbox_inches='tight', dpi=fig.dpi)    
     fig.clf()
     
 def draw_subregions(subregions, lats, lons, fname, fmt='png', ptitle='',
@@ -401,7 +426,7 @@ def draw_subregions(subregions, lats, lo
     fig.clf()
 
 def draw_time_series(datasets, times, labels, fname, fmt='png', gridshape=(1, 1), 
-                     label='', ylabel='', ptitle='', subtitles=None, 
+                     xlabel='', ylabel='', ptitle='', subtitles=None, 
                      label_month=False, yscale='linear'):
     '''
     Purpose::
@@ -660,7 +685,7 @@ def draw_contour_map(dataset, lats, lons
     fig.clf()
 
 def draw_portrait_diagram(datasets, rowlabels, collabels, fname, fmt='png', 
-                          ridshape=(1, 1), xlabel='', ylabel='', clabel='', 
+                          gridshape=(1, 1), xlabel='', ylabel='', clabel='', 
                           ptitle='', subtitles=None, cmap=None, clevs=None, 
                           nlevs=10, extend='neither'):
     '''



Mime
View raw message