allow -c list, fix bar colors

This commit is contained in:
Matt Mackall 2009-04-07 14:59:41 -07:00
commit 49fe263577

6
smem
View file

@ -390,6 +390,7 @@ def showsystem():
showtable(range(len(l)), fields, columns.split(), options.sort or 'order') showtable(range(len(l)), fields, columns.split(), options.sort or 'order')
def showfields(fields, f): def showfields(fields, f):
if f != list:
print "unknown field", f print "unknown field", f
print "known fields:" print "known fields:"
for l in sorted(fields.keys()): for l in sorted(fields.keys()):
@ -521,11 +522,14 @@ def showbar(l, columns, sort):
width = 1.0 / (len(rc) + 1) width = 1.0 / (len(rc) + 1)
offset = width / 2 offset = width / 2
def gc(n):
return 'bgrcmyw'[n % 7]
pl = [] pl = []
ind = numpy.arange(len(l)) ind = numpy.arange(len(l))
for n in xrange(len(rc)): for n in xrange(len(rc)):
pl.append(pylab.bar(ind + offset + width * n, pl.append(pylab.bar(ind + offset + width * n,
[x[1][rc[n]] for x in l], width)) [x[1][rc[n]] for x in l], width, color=gc(n)))
#plt.xticks(ind + .5, ) #plt.xticks(ind + .5, )
pylab.legend([p[0] for p in pl], key) pylab.legend([p[0] for p in pl], key)