Remi Meier avatar Remi Meier committed 9f5d327

stm: add legend to plot

Comments (0)

Files changed (1)

pypy/tool/plot_log.py

     bars = ax.broken_barh(coords, (y+0.1, BOX_HEIGHT),
                           facecolors=colors,
                           picker=True, antialiased=False, rasterized=True)
+
     bars.boxes = boxes
 
 def plot_hlines(hlines, y, ax):
 
         if program_aborted is not None:
             k = ax.plot(program_aborted, tid+HALF_HEIGHT, 'wo',
-                        markersize=30, mew=5, mec='r',
+                        markersize=15, mew=3, mec='r',
                         picker=True, antialiased=False, rasterized=True)
             [setattr(m, "info", str(tid)) for m in k]
 
 
     plt.xlabel("Runtime")
     plt.ylabel("Thread")
+    plt.yticks([r+0.5 for r in range(len(logs))],
+               range(1, len(logs)+1))
 
+    # legend-drawing
+    from matplotlib.font_manager import FontProperties
+    fontP = FontProperties()
+    fontP.set_size('small')
+
+    from matplotlib.patches import Rectangle
+    from matplotlib.lines import  Line2D
+    h = []; l=[]
+    l += ['Successful Transaction']; h += [Rectangle((0, 0), 1, 1, fc="g")]
+    l += ['Transaction turning inevitable']
+    h += [Rectangle((0, 0), 1, 1, fc="b")]
+    l += ['Transaction turned inevitable']
+    h += [Rectangle((0, 0), 1, 1, fc="orange")]
+    l += ['Aborted Transaction']; h += [Rectangle((0, 0), 1, 1, fc="r")]
+    l += ['Thread Start']
+    h += [Line2D((0,0),(0,0), marker='>', mfc='c', ls='', ms=8)]
+    l += ['Thread End']
+    h += [Line2D((0,0),(0,0), marker='<', mfc='c', ls='', ms=8)]
+    l += ['Thread Continuing']
+    h += [Line2D((0,0),(0,0), marker='*', mfc='y', ls='', ms=8)]
+    l += ['Program Abort']
+    h += [Line2D((0,0),(0,0), marker='o', mfc='w', ls='', ms=15, mew=3,mec='r')]
+    l += ['Should Commit']
+    h += [Line2D((0,0),(0,0), marker='+', mec='y', ls='', ms=8, mew=2,)]
+    if args.atomic:
+        l += ['Atomic block']
+        h += [Line2D((0,0),(0,0), c='magenta', lw=3)]
+
+    box = ax.get_position()
+    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
+
+    ax.legend(h, l, numpoints=1,
+              bbox_to_anchor=(1.01, 1), loc=2,
+              prop=fontP)
+
+    # event connect
     fig.canvas.mpl_connect('pick_event', onpick)
 
     plt.draw()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.