Revision: 7432
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7432&view=rev
Author:   jdh2358
Date:     2009-08-08 15:16:57 +0000 (Sat, 08 Aug 2009)

Log Message:
-----------
simplify poly array in example

Modified Paths:
--------------
    branches/v0_99_maint/examples/api/histogram_path_demo.py

Modified: branches/v0_99_maint/examples/api/histogram_path_demo.py
===================================================================
--- branches/v0_99_maint/examples/api/histogram_path_demo.py    2009-08-08 
15:10:08 UTC (rev 7431)
+++ branches/v0_99_maint/examples/api/histogram_path_demo.py    2009-08-08 
15:16:57 UTC (rev 7432)
@@ -22,34 +22,25 @@
 data = np.random.randn(1000)
 n, bins = np.histogram(data, 50)
 
-
 # get the corners of the rectangles for the histogram
 left = np.array(bins[:-1])
 right = np.array(bins[1:])
 bottom = np.zeros(len(left))
 top = bottom + n
-nrects = len(left)
 
-XY = np.zeros((nrects, 4, 2))
-XY[:,0,0] = left
-XY[:,0,1] = bottom
 
-XY[:,1,0] = left
-XY[:,1,1] = top
+# we need a (numrects x numsides x 2) numpy array for the path helper
+# function to build a compound path
+XY = np.array([[left,left,right,right], [bottom,top,top,bottom]]).T
 
-XY[:,2,0] = right
-XY[:,2,1] = top
-
-XY[:,3,0] = right
-XY[:,3,1] = bottom
-
-
-
+# get the Path object
 barpath = path.Path.make_compound_path_from_polys(XY)
-print barpath.codes[:7], barpath.codes[-7:]
+
+# make a patch out of it
 patch = patches.PathPatch(barpath, facecolor='blue', edgecolor='gray', 
alpha=0.8)
 ax.add_patch(patch)
 
+# update the view limits
 ax.set_xlim(left[0], right[-1])
 ax.set_ylim(bottom.min(), top.max())
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to