当前位置: 首页>>代码示例>>Python>>正文


Python seaborn.heatmap方法代码示例

本文整理汇总了Python中seaborn.heatmap方法的典型用法代码示例。如果您正苦于以下问题:Python seaborn.heatmap方法的具体用法?Python seaborn.heatmap怎么用?Python seaborn.heatmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在seaborn的用法示例。


在下文中一共展示了seaborn.heatmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plotSigHeats

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plotSigHeats(signals,markets,start=0,step=2,size=1,iters=6):
    """
    打印信号回测盈损热度图,寻找参数稳定岛
    """
    sigMat = pd.DataFrame(index=range(iters),columns=range(iters))
    for i in range(iters):
        for j in range(iters):
            climit = start + i*step
            wlimit = start + j*step
            caps,poss = plotSigCaps(signals,markets,climit=climit,wlimit=wlimit,size=size,op=False)
            sigMat[i][j] = caps[-1]
    sns.heatmap(sigMat.values.astype(np.float64),annot=True,fmt='.2f',annot_kws={"weight": "bold"})
    xTicks   = [i+0.5 for i in range(iters)]
    yTicks   = [iters-i-0.5 for i in range(iters)]
    xyLabels = [str(start+i*step) for i in range(iters)]
    _, labels = plt.yticks(yTicks,xyLabels)
    plt.setp(labels, rotation=0)
    _, labels = plt.xticks(xTicks,xyLabels)
    plt.setp(labels, rotation=90)
    plt.xlabel('Loss Stop @')
    plt.ylabel('Profit Stop @')
    return sigMat 
开发者ID:rjj510,项目名称:uiKLine,代码行数:24,代码来源:visFunction.py

示例2: time_align_visualize

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def time_align_visualize(alignments, time, y, namespace='time_align'):
    plt.figure()
    heat = np.flip(alignments + alignments.T +
                   np.eye(alignments.shape[0]), axis=0)
    sns.heatmap(heat, cmap="YlGnBu", vmin=0, vmax=1)
    plt.savefig(namespace + '_heatmap.svg')

    G = nx.from_numpy_matrix(alignments)
    G = nx.maximum_spanning_tree(G)

    pos = {}
    for i in range(len(G.nodes)):
        pos[i] = np.array([time[i], y[i]])

    mst_edges = set(nx.maximum_spanning_tree(G).edges())
    
    weights = [ G[u][v]['weight'] if (not (u, v) in mst_edges) else 8
                for u, v in G.edges() ]
    
    plt.figure()
    nx.draw(G, pos, edges=G.edges(), width=10)
    plt.ylim([-1, 1])
    plt.savefig(namespace + '.svg') 
开发者ID:brianhie,项目名称:scanorama,代码行数:25,代码来源:time_align.py

示例3: spatial_heatmap

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def spatial_heatmap(array, path, title=None, color="Greens", figformat="png"):
    """Taking channel information and creating post run channel activity plots."""
    logging.info("Nanoplotter: Creating heatmap of reads per channel using {} reads."
                 .format(array.size))
    activity_map = Plot(
        path=path + "." + figformat,
        title="Number of reads generated per channel")
    layout = make_layout(maxval=np.amax(array))
    valueCounts = pd.value_counts(pd.Series(array))
    for entry in valueCounts.keys():
        layout.template[np.where(layout.structure == entry)] = valueCounts[entry]
    plt.figure()
    ax = sns.heatmap(
        data=pd.DataFrame(layout.template, index=layout.yticks, columns=layout.xticks),
        xticklabels="auto",
        yticklabels="auto",
        square=True,
        cbar_kws={"orientation": "horizontal"},
        cmap=color,
        linewidths=0.20)
    ax.set_title(title or activity_map.title)
    activity_map.fig = ax.get_figure()
    activity_map.save(format=figformat)
    plt.close("all")
    return [activity_map] 
开发者ID:wdecoster,项目名称:NanoPlot,代码行数:27,代码来源:spatial_heatmap.py

示例4: test_plot_SignaturePhMag

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def test_plot_SignaturePhMag(fig_test, fig_ref):

    # fig test
    ext = extractors.Signature()
    kwargs = ext.get_default_params()
    kwargs.update(
        feature="SignaturePhMag",
        value=[[1, 2, 3, 4]],
        ax=fig_test.subplots(),
        plot_kws={},
        time=[1, 2, 3, 4],
        magnitude=[1, 2, 3, 4],
        error=[1, 2, 3, 4],
        features={"PeriodLS": 1, "Amplitude": 10},
    )
    ext.plot(**kwargs)

    # expected
    eax = fig_ref.subplots()
    eax.set_title(
        f"SignaturePhMag - {kwargs['phase_bins']}x{kwargs['mag_bins']}"
    )
    eax.set_xlabel("Phase")
    eax.set_ylabel("Magnitude")
    sns.heatmap(kwargs["value"], ax=eax, **kwargs["plot_kws"]) 
开发者ID:quatrope,项目名称:feets,代码行数:27,代码来源:test_ext_signature.py

示例5: plot_heatmap

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_heatmap(
        D, xordering=None, yordering=None, xticklabels=None,
        yticklabels=None, vmin=None, vmax=None, ax=None):
    import seaborn as sns
    D = np.copy(D)

    if ax is None:
        _, ax = plt.subplots()
    if xticklabels is None:
        xticklabels = np.arange(D.shape[0])
    if yticklabels is None:
        yticklabels = np.arange(D.shape[1])
    if xordering is not None:
        xticklabels = xticklabels[xordering]
        D = D[:,xordering]
    if yordering is not None:
        yticklabels = yticklabels[yordering]
        D = D[yordering,:]

    sns.heatmap(
        D, yticklabels=yticklabels, xticklabels=xticklabels,
        linewidths=0.2, cmap='BuGn', ax=ax, vmin=vmin, vmax=vmax)
    ax.set_xticklabels(xticklabels, rotation=90)
    ax.set_yticklabels(yticklabels, rotation=0)
    return ax 
开发者ID:probcomp,项目名称:cgpm,代码行数:27,代码来源:plots.py

示例6: _plot_weights

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def _plot_weights(self, title, file, layer_index=0, vmin=-5, vmax=5):
        import seaborn as sns
        sns.set_context("paper")

        layers = self.iwp.estimator.steps[-1][1].coefs_
        layer = layers[layer_index]
        f, ax = plt.subplots(figsize=(18, 12))
        weights = pd.DataFrame(layer)
        weights.index = self.iwp.inputs

        sns.set(font_scale=1.1)

        # Draw a heatmap with the numeric values in each cell
        sns.heatmap(
            weights, annot=True, fmt=".1f", linewidths=.5, ax=ax,
            cmap="difference", center=0, vmin=vmin, vmax=vmax,
            # annot_kws={"size":14},
        )
        ax.tick_params(labelsize=18)
        f.tight_layout()
        f.savefig(file) 
开发者ID:atmtools,项目名称:typhon,代码行数:23,代码来源:common.py

示例7: plot_heat

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_heat(ax, sat_delta_ti, min_limit):
  """ Plot satmut deltas.

    Args:
        ax (Axis): matplotlib axis to plot to.
        sat_delta_ti (4 x L_sm array): Single target delta matrix for saturated mutagenesis region,
        min_limit (float): Minimum heatmap limit.
    """
  vlim = max(min_limit, abs(sat_delta_ti).max())
  sns.heatmap(
      sat_delta_ti,
      linewidths=0,
      cmap='RdBu_r',
      vmin=-vlim,
      vmax=vlim,
      xticklabels=False,
      ax=ax)
  ax.yaxis.set_ticklabels('ACGT', rotation='horizontal')  # , size=10) 
开发者ID:calico,项目名称:basenji,代码行数:20,代码来源:basenji_sat_h5.py

示例8: plot_kernel

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_kernel(kernel_weights, out_pdf):
    depth, width = kernel_weights.shape
    fig_width = 2 + 1.5*np.log2(width)

    # normalize
    kernel_weights -= kernel_weights.mean(axis=0)

    # plot
    sns.set(font_scale=1.5)
    plt.figure(figsize=(fig_width, depth))
    sns.heatmap(kernel_weights, cmap='PRGn', linewidths=0.2, center=0)
    ax = plt.gca()
    ax.set_xticklabels(range(1,width+1))

    if depth == 4:
        ax.set_yticklabels('ACGT', rotation='horizontal')
    else:
        ax.set_yticklabels(range(1,depth+1), rotation='horizontal')

    plt.savefig(out_pdf)
    plt.close() 
开发者ID:calico,项目名称:basenji,代码行数:23,代码来源:basenji_motifs_denovo.py

示例9: plot_heat

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_heat(ax, sat_delta_ti, min_limit):
  """ Plot satmut deltas.

    Args:
        ax (Axis): matplotlib axis to plot to.
        sat_delta_ti (4 x L_sm array): Single target delta matrix for saturated mutagenesis region,
        min_limit (float): Minimum heatmap limit.
    """

  vlim = max(min_limit, np.nanmax(np.abs(sat_delta_ti)))
  sns.heatmap(
      sat_delta_ti,
      linewidths=0,
      cmap='RdBu_r',
      vmin=-vlim,
      vmax=vlim,
      xticklabels=False,
      ax=ax)
  ax.yaxis.set_ticklabels('ACGT', rotation='horizontal')  # , size=10) 
开发者ID:calico,项目名称:basenji,代码行数:21,代码来源:basenji_sat_plot.py

示例10: plot_heat

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_heat(ax, sat_score_ti, min_limit=None):
  """ Plot satmut deltas.

    Args:
        ax (Axis): matplotlib axis to plot to.
        sat_delta_ti (L_sm x 4 array): Single target delta matrix for saturated mutagenesis region,
    """

  if np.max(sat_score_ti) < min_limit:
    vmax = min_limit
  else:
    vmax = None

  sns.heatmap(
      sat_score_ti.T,
      linewidths=0,
      xticklabels=False,
      yticklabels=False,
      cmap='Blues',
      vmax=vmax,
      ax=ax)

  # yticklabels break the plot for some reason
  # ax.yaxis.set_ticklabels('ACGT', rotation='horizontal') 
开发者ID:calico,项目名称:basenji,代码行数:26,代码来源:akita_sat_vcf.py

示例11: heatmap

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def heatmap(self, pct_change=False, **kwargs):
        """
        Generate a seaborn heatmap for correlations between assets.

        Parameters:
            - pct_change: Whether or not to show the correlations of the
                          daily percent change in price or just use
                          the closing price.
            - kwargs: Keyword arguments to pass down to `sns.heatmap()`

        Returns:
            A seaborn heatmap
        """
        pivot = self.data.pivot_table(
            values='close', index=self.data.index, columns='name'
        )
        if pct_change:
            pivot = pivot.pct_change()
        return sns.heatmap(pivot.corr(), annot=True, center=0, **kwargs) 
开发者ID:stefmolin,项目名称:stock-analysis,代码行数:21,代码来源:stock_visualizer.py

示例12: plot_dailyhold

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_dailyhold(self, start=None, end=None):
        """
        使用热力图画出每日持仓
        """
        start = self.account.start_date if start is None else start
        end = self.account.end_date if end is None else end
        _, ax = plt.subplots(figsize=(20, 8))
        sns.heatmap(self.account.daily_hold.reset_index().set_index('date').loc[start:end],
            cmap="YlGnBu",
            linewidths=0.05,
            ax=ax)
        ax.set_title('HOLD TABLE --ACCOUNT: {}'.format(self.account.account_cookie))
        ax.set_xlabel('Code')
        ax.set_ylabel('DATETIME')

        return plt 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:18,代码来源:QARisk.py

示例13: plot_signal

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_signal(self, start=None, end=None):
        """
        使用热力图画出买卖信号
        """
        start = self.account.start_date if start is None else start
        end = self.account.end_date if end is None else end
        _, ax = plt.subplots(figsize=(20, 18))
        sns.heatmap(self.account.trade.reset_index().drop('account_cookie',
                axis=1).set_index('datetime').loc[start:end],
            cmap="YlGnBu",
            linewidths=0.05,
            ax=ax)
        ax.set_title('SIGNAL TABLE --ACCOUNT: {}'.format(self.account.account_cookie))
        ax.set_xlabel('Code')
        ax.set_ylabel('DATETIME')
        return plt 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:18,代码来源:QARisk.py

示例14: plot_unsmoothed

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_unsmoothed():
    corpus, T = generate_corpus()
    L = LDA(T)
    L.train(corpus, verbose=False)

    fig, axes = plt.subplots(1, 2)
    ax1 = sns.heatmap(L.beta, xticklabels=[], yticklabels=[], ax=axes[0])
    ax1.set_xlabel("Topics")
    ax1.set_ylabel("Words")
    ax1.set_title("Recovered topic-word distribution")

    ax2 = sns.heatmap(L.gamma, xticklabels=[], yticklabels=[], ax=axes[1])
    ax2.set_xlabel("Topics")
    ax2.set_ylabel("Documents")
    ax2.set_title("Recovered document-topic distribution")

    plt.savefig("img/plot_unsmoothed.png", dpi=300)
    plt.close("all") 
开发者ID:ddbourgin,项目名称:numpy-ml,代码行数:20,代码来源:lda_plots.py

示例15: plot_embedding

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import heatmap [as 别名]
def plot_embedding(embed:OrderedDict, feat:str, savename:Optional[str]=None, settings:PlotSettings=PlotSettings()) -> None:
    r'''
    Visualise weights in provided categorical entity-embedding matrix

    Arguments:
        embed: state_dict of trained nn.Embedding
        feat: name of feature embedded
        savename: Optional name of file to which to save the plot of feature importances
        settings: :class:`~lumin.plotting.plot_settings.PlotSettings` class to control figure appearance
    '''

    with sns.axes_style(**settings.style):
        plt.figure(figsize=(settings.w_small, settings.h_small))
        sns.heatmap(to_np(embed['weight']), annot=True, fmt='.1f', linewidths=.5, cmap=settings.div_palette, annot_kws={'fontsize':settings.leg_sz})
        plt.xlabel("Embedding", fontsize=settings.lbl_sz, color=settings.lbl_col)
        plt.ylabel(feat, fontsize=settings.lbl_sz, color=settings.lbl_col)
        plt.xticks(fontsize=settings.tk_sz, color=settings.tk_col)
        plt.yticks(fontsize=settings.tk_sz, color=settings.tk_col)
        plt.title(settings.title, fontsize=settings.title_sz, color=settings.title_col, loc=settings.title_loc)
        if savename is not None: plt.savefig(settings.savepath/f'{savename}{settings.format}', bbox_inches='tight')
        plt.show() 
开发者ID:GilesStrong,项目名称:lumin,代码行数:23,代码来源:interpretation.py


注:本文中的seaborn.heatmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。