A Python reproduction of the MATLAB Special Heatmap project.
Project description
Python Special Heatmap
Disclaimer: This project was implemented with the assistance of AI (Google Gemini).
声明:本项目代码由 AI (Google Gemini) 辅助生成。
介绍 / Introduction
A Python reproduction of the MATLAB special heatmap project. It uses matplotlib to draw advanced heatmaps with various shapes (square, circle, hexagon, pie, etc.) and triangular layouts.
基于 MATLAB 版 special heatmap 的 Python 复现。本项目使用 matplotlib 实现具有多种形状(正方形、圆形、六边形、饼图等)和三角矩阵布局的高级热图绘制。
1. 安装 / Installation
pip install special-heatmap
2. 基础使用 / Basic Use
2.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()
2.2 绘制含负数热图 (Contains negative numbers)
data = np.random.rand(15, 15) - 0.5
shm = SHeatmap(data, fmt='sq')
shm.draw()
plt.show()
2.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(fontsize=8)
plt.show()
3. 各类型热图 / Various Formats
支持的格式 (fmt 参数): sq (Default), pie, circ, oval, hex, asq, acirc.
# 示例:绘制饼图格式
shm = SHeatmap(data, fmt='pie')
shm.draw()
| Format | Positive Data (A) | Mixed Data (B) |
|---|---|---|
| sq (Square) | ||
| pie (Pie Chart) | ||
| circ (Circle) | ||
| hex (Hexagon) | ||
| oval (Oval) | ||
| asq (Auto-Square) | ||
| acirc (Auto-Circle) |
4. 三角布局 / Triangular Layouts
支持以下布局类型 (set_type 方法):
triu: 上三角 (Upper Triangle)tril: 下三角 (Lower Triangle)triu0: 上三角无对角线 (Upper without Diagonal)tril0: 下三角无对角线 (Lower without Diagonal)
data = np.random.rand(12, 12)
shm = SHeatmap(data, fmt='sq')
shm.set_type('tril') # 设置为下三角
shm.draw()
shm.set_text()
plt.show()
| Type | Result |
|---|---|
| triu | |
| tril | |
| triu0 | |
| tril0 |
5. 开源协议 / License
本项目采用 GPL v2 开源协议。详细内容请参阅 LICENSE 文件。 This project is licensed under the GPL v2 License. See the LICENSE file for details.
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
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.2.0.tar.gz.
File metadata
- Download URL: special_heatmap-0.2.0.tar.gz
- Upload date:
- Size: 2.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30e0a03cf321390b4af5f6e563e8befb1263f7a795a026097fc5e2ebc1cd1e7c
|
|
| MD5 |
569da969788b6ce09aae00303ed27444
|
|
| BLAKE2b-256 |
f54414bb2ad9d1a244c0fe044b751c15f935c849f0a2f31c20a2e37b3c167464
|
File details
Details for the file special_heatmap-0.2.0-py3-none-any.whl.
File metadata
- Download URL: special_heatmap-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.2 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 |
eb2b05a182953cc6f872e6e95155c9885d1e017e17c1a3ced2d2e07c9c229883
|
|
| MD5 |
12967aee5373433deb4eef9709965640
|
|
| BLAKE2b-256 |
d1f9dcb45528a3951ea5057dacc12a5e4496a008b7a8b850f2b4f4a5eadf1dec
|