Skip to main content

A simple rich renderable Heatmap.

Project description

PyPI version

rich_heatmap

A simple Heatmap renderable for projects using rich.

Installing

Install with pip or your favorite package manager:

python -m pip install rich_heatmap
uv add rich_heatmap

Usage

Create HeatmapCell objects containing your data:

for row, col in itertools.product(range(30), range(20)):
    value = noise.snoise2(col / 10, row / 15)
    cells.append(heatmap.HeatmapCell(row, col, value, None, f"{value:0.1f}"))

Values will be normalized into [0, 1] and then mapped to a color using the colormap function:

EMBER = matplotlib.colormaps['cmr.ember']
def colormap(value: float) -> tuple[float, float, float]:
	rgba = EMBER(value)
	return rich.color.Color.from_rgb(
		255 * rgba[0],
		255 * rgba[1],
		255 * rgba[2],
	)

And then print a Heatmap containing those cells:

print(heatmap.Heatmap(cells=cells, colormap=colormap))

Row and column values will be sorted before printing, so you can accumulate a stream of data and feed it in without any more trouble:

Heatmap example image

If you don't provide text, the library will produce rectangular cells:

Heatmap example image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rich_heatmap-0.1.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rich_heatmap-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file rich_heatmap-0.1.1.tar.gz.

File metadata

  • Download URL: rich_heatmap-0.1.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rich_heatmap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f15884e93ed0a6720b190ad34dc0b178bf1fa9f6ee6c9bdf300c30323585211c
MD5 d625ea50a4bcd9e58743017b0b37d7c5
BLAKE2b-256 1cc426b5b1bc4c4a5856c15964191a641352efe95ee8ed0f3d2755d14e77c69a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_heatmap-0.1.1.tar.gz:

Publisher: publish.yml on saulrh/rich_heatmap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rich_heatmap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rich_heatmap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rich_heatmap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0106c1aa0ec9b22d6214f9395a3201e24c98c2245db1f3a62867c703438362c6
MD5 39de75fc60fa71ac8b5d53864b7fb5ef
BLAKE2b-256 0b4ef008ca329527ecf8ce697fb4e5c160ddff5451c5a9ef0410af37cdbfce48

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_heatmap-0.1.1-py3-none-any.whl:

Publisher: publish.yml on saulrh/rich_heatmap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page