c2v.pl.heatmap

Contents

c2v.pl.heatmap#

c2v.pl.heatmap(df, cmap='RdBu_r', linecolor='black', linewidth=0.5, borderwidth_hm=2.0, square=True, cbar_scale=0.6, cbar_aspect=20.0, cbar_pad=0.025, cmap_border=1.0, cbar_title='', ax=None, x_rotation=0.0, y_rotation=0.0, xlabels=True, ylabels=True, sort_columns=True, sort_rows=False, linkage_method='average', linkage_metric='euclidean', return_fig=False, title=None, show=True, figsize=None, **kwargs)#

Draws pretty heatmap.

Parameters:
df pd.DataFrame

DataFrame to be visualized.

cmap str, optional

Colormap to be used. Default is “RdBu_r”.

linecolor str, optional

Color of the lines between cells. Default is “black”.

linewidth float, optional

Width of the lines between cells. Default is 0.5.

borderwidth_hm float, optional

Width of the border around the heatmap. Default is 2.

square bool, optional

Whether to make cells square. Default is True.

cbar_scale float, optional

Scale of the colorbar. Default is 0.6.

cbar_aspect float, optional

Aspect ratio of the colorbar. Default is 20.

cbar_pad float, optional

Padding between the heatmap and the colorbar. Default is 0.025.

cmap_border float, optional

Width of the border around the colormap. Default is 1.

cbar_title str, optional

Title of the colorbar. Default is “”.

ax plt.Axes | None, optional

Axes object to draw the heatmap on. Default is None.

x_rotation float, optional

Rotation angle for x-axis labels. Default is 0.

y_rotation float, optional

Rotation angle for y-axis labels. Default is 0.

xlabels bool, optional

Whether to show x-axis labels. Default is True.

ylabels bool, optional

Whether to show y-axis labels. Default is True.

sort_columns bool, optional

Whether to hierarchically sort columns for display. Default is False.

sort_rows bool, optional

Whether to hierarchically sort rows for display. Default is False.

linkage_method str, optional

Linkage method for hierarchical clustering. Default is “average”.

linkage_metric str, optional

Linkage metric for hierarchical clustering. Default is “euclidean”.

return_fig bool, optional

Whether to return the figure object. Default is False.

title str | None, optional

Title for the plot. Default is None.

show bool, optional

Whether to show the plot. Default is True.

figsize tuple[float, float] | None, optional

Figure size. Default is None.

**kwargs

Additional keyword arguments for sns.heatmap().

Return type:

Figure | Axes | None

Returns:

fig : plt.Figure | plt.Axes | None Figure object if return_fig is True, Axes if show is False, otherwise None.