File: bar_unit_demo.py

package info (click to toggle)
matplotlib 0.98.1-1%2Blenny4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,624 kB
  • ctags: 22,599
  • sloc: python: 76,915; cpp: 63,459; ansic: 5,353; makefile: 111; sh: 12
file content (30 lines) | stat: -rw-r--r-- 848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
from basic_units import cm, inch
from pylab import figure, show,nx

N = 5
menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm)
menStd =   ( 20*cm,  30*cm,  32*cm,  10*cm,  20*cm)

fig = figure()
ax = fig.add_subplot(111)

ind = nx.arange(N)    # the x locations for the groups
width = 0.35         # the width of the bars
p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd)


womenMeans = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm)
womenStd =   (30*cm, 25*cm, 20*cm, 31*cm, 22*cm)
p2 = ax.bar(ind+width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd)

ax.set_title('Scores by group and gender')
ax.set_xticks(ind+width)
ax.set_xticklabels( ('G1', 'G2', 'G3', 'G4', 'G5') )

ax.legend( (p1[0], p2[0]), ('Men', 'Women') )
ax.yaxis.set_units(inch)
ax.autoscale_view()

#savefig('barchart_demo')
show()