基于python的热力图heatmap函数使用

一、标出库引用

import seaborn as sns

二、函数具体使用

sns.heatmap(temp, annot=True, square=True, cmap="Blues)
plt.show()

其中,temp是n个变量构成的n*n的互相关系数矩阵,是DataFrame格式,其余参数是自己设定的参数。

三、参数说明

def heatmap(
    data, *,
    vmin=None, vmax=None, cmap=None, center=None, robust=False,
    annot=None, fmt=".2g", annot_kws=None,
    linewidths=0, linecolor="white",
    cbar=True, cbar_kws=None, cbar_ax=None,
    square=False, xticklabels="auto", yticklabels="auto",
    mask=None, ax=None,
    **kwargs
):

将矩形数据绘制为颜色编码矩阵。
参数分析:


 1. data : rectangular datase 2D dataset that can be coerced into an
    ndarray. If a Pandas DataFram is provided, the index/column
    information will be used to label the columns and rows.
 2. vmin, vmax : floats, optional Values to anchor the colormap,
    otherwise they are inferred from the data and other keyword
    arguments.
 3. cmap : matplotlib colormap name or object, or list of colors,
    optional. The mapping from data values to color space. If not
    provided, the default will depend on whether ``center`` is set.
 4. center : float, optional.                                           
    The value at which to center the colormap when plotting divergant
    data.Using this parameter will change the default ``cmap`` if none
    is specified.
 5. robust : bool, optional                                             
    If True and ``vmin`` or ``vmax`` are absent, the colormap range is
    computed with robust quantiles instead of the extreme values.
 
 6. annot : bool or rectangular dataset, optional.If True, write the data value in each cell. If an array-like with the same shape as ``data``, then use this to annotate the heatmap instead of the data. Note that DataFrames will match on position, not index.
 7. fmt : str, optional                                                 
  String formatting code to use when adding annotations.
 8. annot_kws : dict of key, value mappings, optional
Keyword arguments for :meth:`matplotlib.axes.Axes.text` when ``annot`` is True.
 
 9. linewidths : float, optional
                 Width of the lines that will divide each cell.
 10. linecolor : color, optional
             Color of the lines that will divide each cell.
 11. cbar : bool, optional
   Whether to draw a colorbar.
 12. cbar_kws : dict of key, value mappings, optional 
 Keyword arguments for :meth:`matplotlib.figure.Figure.colorbar`.
 13. cbar_ax : matplotlib Axes, optional
   Axes in which to draw the colorbar, otherwise take space from the main Axes.
 14. square : bool, optional
 If True, set the Axes aspect to "equal" so each cell will be square-shaped.
 15. xticklabels, yticklabels : "auto", bool, list-like, or int,
     optional
  If True, plot the column names of the dataframe. If False, don't plot  the column names. If list-like, plot these alternate labels as the xticklabels. If an integer, use the column names but plot only every  n label. If "auto", try to densely plot non-overlapping labels.
 16. mask : bool array or DataFrame, optional
 If passed, data will not be shown in cells where ``mask`` is True.
 Cells with missing values are automatically masked.
 17. ax : matplotlib Axes, optional  
Axes in which to draw the plot, otherwise use the currently-active  
 18. Axes.kwargs : other keyword arguments
   All other keyword arguments are passed to
   :meth:`matplotlib.axes.Axes.pcolormesh`.
 19. Returns
             -------
             ax : matplotlib Axes
                 Axes object with the heatmap.
     
     ```

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Kiki酱。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值