]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
scripts/parse-depmod: use anchored text
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 14 Aug 2013 05:01:08 +0000 (02:01 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 20 Sep 2013 19:35:52 +0000 (14:35 -0500)
scripts/parse-depmod

index 87cd31c5dc5a748c47166295f308bcb354731d05..3ff8a8bc715b06dddd7fcdac10152fc6f32f43c0 100755 (executable)
@@ -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')