import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cm

class SlicePlotter(object):
   def __init__(self, slice_batch):
      self.slice_batch = slice_batch

   def sizePlot(self, scale='linear'):
      """
      Plots an edleak slice batch as a scatter plot with the size on the x axis.
      This is the default and recommended plot type for visual analysis.
      """
      slice_count = len(self.slice_batch)
      context_count = len(self.slice_batch[slice_count-1])

      x = np.zeros([context_count], int)
      y = np.r_[0:context_count]

      greens = plt.get_cmap('Greens')
      cnorm  = colors.Normalize(vmin=0, vmax=slice_count)
      scalar_map = cm.ScalarMappable(norm=cnorm, cmap=greens)

      ax = plt.subplot(111)
      slice_index = 0
      for current_slice in self.slice_batch:
         for alloc_point in current_slice:
            x[alloc_point['alc']] = alloc_point['mem']
         color_value = scalar_map.to_rgba(slice_index)
         ax.scatter(x, y, c=color_value, s=60, edgecolors='none')
         slice_index += 1

      if scale == 'log':
         ax.set_xscale('log')
      plt.show()

@@ -1171,8 +1171,1117 @@
 .show()%0A
+%0A   def timePlot(self, scale='linear', allocers=None):%0A      %22%22%22%0A      Plots an edleak slice batch as a scatter plot with the time on the x axis.%0A      %22%22%22%0A      slice_count = len(self.slice_batch)%0A      context_count = len(self.slice_batch%5Bslice_count-1%5D)%0A%0A      x = np.r_%5B0:slice_count%5D%0A      y = np.zeros((context_count, slice_count), int)%0A%0A      greens = plt.get_cmap('Greens')%0A      cnorm  = colors.Normalize(vmin=0, vmax=context_count)%0A      scalar_map = cm.ScalarMappable(norm=cnorm, cmap=greens)%0A%0A      ax = plt.subplot(111)%0A      slice_index = 0%0A      for current_slice in self.slice_batch:%0A         for alloc_point in current_slice:%0A            y%5Balloc_point%5B'alc'%5D%5D%5Bslice_index%5D = alloc_point%5B'mem'%5D%0A         slice_index += 1%0A%0A      context_index = 0%0A      while context_index %3C context_count:%0A         if allocers == None or context_index in allocers:%0A            color_value = scalar_map.to_rgba(context_index)%0A            ax.scatter(x, y%5Bcontext_index%5D, c=color_value, s=60, edgecolors='none')%0A         context_index += 1%0A%0A      if scale == 'log':%0A         ax.set_yscale('log')%0A      plt.show()%0A

Add edleak time plot