mosaic_heatmap
mosaic_heatmap(data, ...)
Plot mosaic data as a color-encoded matrix.
Creates a mosaic heatmap where the column widths and row heights are proportional to the marginal sums of the data matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
array - like
|
2D dataset that can be coerced into an ndarray. If a pandas DataFrame is provided, the index/column information will be used to label the columns and rows. |
required |
vmin
|
float
|
Values to anchor the colormap. |
None
|
vmax
|
float
|
Values to anchor the colormap. |
None
|
cmap
|
str or Colormap
|
The mapping from data values to color space. |
None
|
center
|
float
|
The value at which to center the colormap for divergent data. |
None
|
robust
|
bool
|
If True, compute colormap range using robust quantiles. |
False
|
annot
|
bool or array - like
|
If True, write the data value in each cell. |
None
|
fmt
|
str
|
String formatting code for annotation values. Default: '.2g' |
'.2g'
|
annot_kws
|
dict
|
Keyword arguments for annotation text. |
None
|
cbar
|
bool
|
Whether to draw a colorbar. Default: True |
True
|
cbar_kws
|
dict
|
Keyword arguments for colorbar. |
None
|
cbar_ax
|
Axes
|
Axes in which to draw the colorbar. |
None
|
square
|
bool
|
If True, set aspect ratio to "equal". Default: False |
False
|
xticklabels
|
(auto, bool, array - like)
|
Tick label specification. |
'auto'
|
yticklabels
|
(auto, bool, array - like)
|
Tick label specification. |
'auto'
|
mask
|
bool array or DataFrame
|
If True in a cell, data is not shown. |
None
|
ax
|
Axes
|
Axes in which to draw the plot. Uses current axes if None. |
None
|
**kwargs
|
dict
|
Additional keyword arguments passed to pcolormesh. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
The Axes object with the heatmap. |
Examples:
>>> import numpy as np
>>> from mheatmap import mosaic_heatmap
>>> data = np.array([[10, 2, 0], [1, 8, 3], [0, 1, 12]])
>>> ax = mosaic_heatmap(data, annot=True, cmap='YlOrRd')
Source code in src/mheatmap/matrix.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |