diff --git a/scripts/parse-depmod b/scripts/parse-depmod index 87cd31c..3ff8a8b 100755 --- a/scripts/parse-depmod +++ b/scripts/parse-depmod @@ -22,8 +22,19 @@ def parse_table(f): y += [v[1]] return x, y -import matplotlib.pyplot as plt import numpy as np +import matplotlib.pyplot as plt +from mpl_toolkits.axes_grid.anchored_artists import AnchoredText + + +def add_at(ax, t, loc=2): + fp = dict(size=9) + _at = AnchoredText(t, loc=loc, prop=fp) + _at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2") + _at.patch.set_alpha(0.8) + _at.patch.set_fc('#A9A9A9') + ax.add_artist(_at) + return _at fig = plt.figure() @@ -33,17 +44,12 @@ with open(sys.argv[1]) as f: fit = np.polyfit(x, y, 1) fit_fn = np.poly1d(fit) - ax = fig.add_subplot(2, 2, i) + 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') - ax.text(0.03, 0.97, - 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y)), - transform=ax.transAxes, - verticalalignment='top', - horizontalalignment='left' - ) + 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')