parse-depmod: Allow to plot all at once

This commit is contained in:
Lucas De Marchi 2013-08-16 00:47:36 -03:00
parent 003cd0020d
commit 3cdd70349e
1 changed files with 25 additions and 17 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
import sys
import os.path
def parse_table(f):
curr = 0
@ -36,23 +36,31 @@ def add_at(ax, t, loc=2):
ax.add_artist(_at)
return _at
fig = plt.figure()
with open(sys.argv[1]) as f:
for i in range(0, 3):
x, y = parse_table(f)
fit = np.polyfit(x, y, 1)
fit_fn = np.poly1d(fit)
figs = []
for fn in sys.argv[1:]:
fig = plt.figure()
figs += [fig]
with open(fn) as f:
for i in range(0, 3):
x, y = parse_table(f)
fit = np.polyfit(x, y, 1)
fit_fn = np.poly1d(fit)
ax = fig.add_subplot(2, 2, i, axisbg='#f6f6f6')
ax.plot(x, y, 'b', x, fit_fn(x), 'r')
ax.set_xlabel('bucket')
ax.set_ylabel('entries')
ax.axis('tight')
add_at(ax, 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y)))
ax.grid(True)
tit = os.path.splitext(os.path.basename(fn))[0]
fig.suptitle('Hash distribution on buckets: %s' % tit, weight='bold',
size='large')
fig.tight_layout()
fig.subplots_adjust(top=0.9)
ax = fig.add_subplot(2, 2, i, axisbg='#f6f6f6')
ax.plot(x, y, 'b', x, fit_fn(x), 'r')
ax.set_xlabel('bucket')
ax.set_ylabel('entries')
ax.axis('tight')
add_at(ax, 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y)))
ax.grid(True)
fig.suptitle('Hash distribution on buckets', weight='bold', size='large')
fig.tight_layout()
plt.subplots_adjust(top=0.9)
plt.show()