def plotCorrelationHeatmapMatplot(counts, outfile, method="correlation",
                                  cor_method="pearson"):
    '''plot a heatmap of correlations derived from
    countsTable.
    '''
    # to do: add other methods?

    # define outside function? - Will we reuse?
    heatmap_cdict_b_to_y = {
        'red': ((0.0, 0.4, .4), (0.01, .4, .4), (1., .95, .95)),
        'green': ((0.0, 0.4, 0.4), (0.01, .4, .4), (1., .95, .95)),
        'blue': ((0.0, .9, .9), (0.01, .9, .9), (1., 0.4, 0.4))}

    cm = matplotlib.colors.LinearSegmentedColormap(
        '', heatmap_cdict_b_to_y, 256)

    df = counts.corr(method=cor_method)
    plt.pcolor(np.array(df), cmap=cm)
    plt.colorbar()
    plt.title("%(cor_method)s correlation heatmap" % locals())
    plt.yticks(np.arange(0.5, len(df.index), 1), df.index)
    plt.xticks(np.arange(0.5, len(df.columns), 1), df.columns, rotation=90)
    plt.tight_layout()
    plt.savefig(outfile)
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Expression.py/plotCorrelationHeatmapMatplot/original