[CalendarServer-changes] [6165] CalendarServer/trunk/contrib/performance/stackedbar.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 20 14:32:54 PDT 2010


Revision: 6165
          http://trac.macosforge.org/projects/calendarserver/changeset/6165
Author:   exarkun at twistedmatrix.com
Date:     2010-08-20 14:32:52 -0700 (Fri, 20 Aug 2010)
Log Message:
-----------
just an example of stacked bar graphs with matplotlib, perhaps to be transformed into something useful later

Added Paths:
-----------
    CalendarServer/trunk/contrib/performance/stackedbar.py

Added: CalendarServer/trunk/contrib/performance/stackedbar.py
===================================================================
--- CalendarServer/trunk/contrib/performance/stackedbar.py	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/stackedbar.py	2010-08-20 21:32:52 UTC (rev 6165)
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# a stacked bar plot with errorbars
+import numpy as np
+import matplotlib.pyplot as plt
+from operator import add
+
+
+N = 5
+menMeans   = (20, 35, 30, 35, 27)
+womenMeans = (25, 32, 34, 20, 25)
+menStd     = (2, 3, 4, 1, 2)
+womenStd   = (3, 5, 2, 3, 3)
+otherMeans  = (15, 30, 25, 40, 35)
+
+ind = np.arange(N)    # the x locations for the groups
+width = 0.35       # the width of the bars: can also be len(x) sequence
+
+p1 = plt.bar(ind, menMeans,   width, color='r', yerr=womenStd)
+p2 = plt.bar(ind, womenMeans, width, color='y',
+             bottom=menMeans, yerr=menStd)
+p3 = plt.bar(ind, otherMeans, width, color='g',
+             bottom=map(add, menMeans, womenMeans), yerr=menStd)
+
+plt.ylabel('Scores')
+plt.title('Scores by group and gender')
+plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
+plt.yticks(np.arange(0,81,10))
+plt.legend( (p1[0], p2[0], p3[0]), ('Men', 'Women', 'Other') )
+
+plt.show()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100820/7fd3cc9f/attachment-0001.html>


More information about the calendarserver-changes mailing list