A Python reproduction of the MATLAB Special Heatmap project.
Project description
Python Special Heatmap
介绍
基于 MATLAB 版 special heatmap 的 Python 复现。本项目使用 matplotlib 实现具有多种形状(正方形、圆形、六边形、饼图等)和三角矩阵布局的高级热图绘制。
1 基础使用 (Basic use)
1.1 绘制正数热图 (Draw positive heat map)
import numpy as np
import matplotlib.pyplot as plt
from special_heatmap import SHeatmap
data = np.random.rand(15, 15)
shm = SHeatmap(data, fmt='sq')
shm.draw()
plt.show()
1.2 绘制含负数热图 (Contains negative numbers)
data = np.random.rand(15, 15) - 0.5
shm = SHeatmap(data, fmt='sq')
shm.draw()
plt.show()
1.3 绘制有文本和 NaN 的热图 (Draw heat map with texts and NaN)
data = np.random.rand(12, 12) - 0.5
data[3, 3] = np.nan
shm = SHeatmap(data, fmt='sq')
shm.draw()
shm.set_text()
plt.show()
2 各类型热图绘制 (Various Formats)
支持的格式 (fmt 参数):
sq: 正方形 (默认)pie: 饼图circ: 圆形oval: 椭圆形hex: 六边形asq: 自动调整大小的正方形acirc: 自动调整大小的圆形
shm = SHeatmap(data, fmt='pie')
shm.draw()
3 设置为上三角或下三角 (Triangular Layouts)
支持以下布局类型 (set_type 方法):
triu: 上三角部分tril: 下三角部分triu0: 不含对角线的上三角部分tril0: 不含对角线的下三角部分
data = np.random.rand(12, 12)
shm = SHeatmap(data, fmt='sq')
shm.set_type('tril')
shm.draw()
shm.set_text()
plt.show()
4 安装与运行
本项目使用 uv 进行环境管理。
# 克隆仓库后进入目录
cd python_reproduction
# 创建虚拟环境并安装依赖
uv sync
# 运行演示脚本
uv run demo_basic.py
已实现功能
- 基础形状绘制 (sq, pie, circ, oval, hex, asq, acirc)
- 自动颜色映射 (Sequential & Diverging)
- NaN 值特殊渲染 (灰块 + '×')
- 数值文本标注
- 上下三角矩阵显示
Original MATLAB project by slandarer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
special_heatmap-0.1.0.tar.gz
(2.3 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file special_heatmap-0.1.0.tar.gz.
File metadata
- Download URL: special_heatmap-0.1.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ebe6e73dedfd1417c9232d324e8e28f8df4b6d04094e5cdec00b5463acf631
|
|
| MD5 |
c53faf22be6b729a033e30680a5f8528
|
|
| BLAKE2b-256 |
e723c2e63017ac4ec42c4546e7f9106154285622d56c43f9452d7bcb087a824c
|
File details
Details for the file special_heatmap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: special_heatmap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b95cb6060ebc4a7f20bd157cde33fc1a0267d05c5da23a7242abc0162f66f2
|
|
| MD5 |
87f619bcbfc76b0470857bb1a4c3084b
|
|
| BLAKE2b-256 |
53a1c6ab85530d32ae9fc4379449c17c24d48276c3f478a0a21d34ef010a1f72
|