Python matplotlib.cm 模块,hot() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用matplotlib.cm.hot()

项目:HiCembler    作者:lpryszcz    | 项目源码 | 文件源码
def plot(outfn, a, genomeSize, base2chr, _windowSize, dpi=300, ext="svg"):
    """Save contact plot"""

    def format_fn(tick_val, tick_pos):
        """Mark axis ticks with chromosome names"""
        if int(tick_val) in base2chr:
            return base2chr[int(tick_val)]
        else:
            sys.stderr.write("[WARNING] %s not in ticks!\n"%tick_val)
            return ''

    # invert base2chr
    base2chr = {genomeSize-b: c for b, c in base2chr.iteritems()}
    # start figure
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.set_title("Contact intensity plot [%sk]"%(_windowSize/1000,))
    # label Y axis with chromosome names
    if len(base2chr)<50:
        ax.yaxis.set_major_formatter(FuncFormatter(format_fn))
        ax.yaxis.set_major_locator(MaxNLocator(integer=True))
        plt.yticks(base2chr.keys())
        ax.set_ylabel("Chromosomes")
    else:
        ax.set_ylabel("Genome position")
    # label axes
    ax.set_xlabel("Genome position")        
    plt.imshow(a+1, cmap=cm.hot, norm=LogNorm(), extent=(0, genomeSize, 0, genomeSize))# 
    plt.colorbar()
    # save
    fig.savefig("%s.%s"%(outfn,ext), dpi=dpi, papertype="a4")
项目:HiCembler    作者:lpryszcz    | 项目源码 | 文件源码
def plot(outfn, a, genomeSize, base2chr, _windowSize, dpi=300, ext="svg"):
    """Save contact plot"""

    def format_fn(tick_val, tick_pos):
        """Mark axis ticks with chromosome names"""
        if int(tick_val) in base2chr:
            return base2chr[int(tick_val)]
        else:
            sys.stderr.write("[WARNING] %s not in ticks!\n"%tick_val)
            return ''

    # invert base2chr
    base2chr = {genomeSize-b: c for b, c in base2chr.iteritems()}
    # start figure
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.set_title("Contact intensity plot [%sk]"%(_windowSize/1000,))
    # label Y axis with chromosome names
    if len(base2chr)<50:
        ax.yaxis.set_major_formatter(FuncFormatter(format_fn))
        ax.yaxis.set_major_locator(MaxNLocator(integer=True))
        plt.yticks(base2chr.keys())
        ax.set_ylabel("Chromosomes")
    else:
        ax.set_ylabel("Genome position")
    # label axes
    ax.set_xlabel("Genome position")        
    plt.imshow(a+1, cmap=cm.hot, norm=LogNorm(), extent=(0, genomeSize, 0, genomeSize))# 
    plt.colorbar()
    # save
    fig.savefig("%s.%s"%(outfn,ext), dpi=dpi, papertype="a4")
项目:DeepMIML    作者:kingfengji    | 项目源码 | 文件源码
def plot_instance_probs_heatmap(instance_probs, save_path=None):
    """
    Arguments:
        instance_probs (ndarray): shape = (n_instances, n_labels)
            the probability distribution of each instance
    """
    n_instances, n_labels = instance_probs.shape
    fig, ax = plt.subplots()
    ax.set_title("Instance-Label Scoring Layer Visualized")

    cax = ax.imshow(instance_probs, vmin=0, vmax=1, cmap=cm.hot, aspect=float(n_labels) / n_instances)
    cbar_ticks = list(np.linspace(0, 1, 11))
    cbar = fig.colorbar(cax, ticks=cbar_ticks)
    cbar.ax.set_yticklabels(map(str, cbar_ticks))

    if save_path:
        if not osp.exists(osp.dirname(save_path)):
            os.makedirs(osp.dirname(save_path))
        fig.savefig(save_path)
    else:
        plt.show()