def draw_matrix(mat, th1=None, th2=None, clim=None, cmap=None): """Draw a matrix, optionally thresholding it. """ if th1 is not None: m2 = tsu.thresholded_arr(mat, th1, th2) else: m2 = mat ax = plt.matshow(m2, cmap=cmap) if clim is not None: ax.set_clim(*clim) plt.colorbar() return ax