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.2.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.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rich_heatmap-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 8372834a8b0d6f34d72f0f48a4724310e9a777e759323a4c83d05c1cf2f35e19
MD5 2f0cd54ab6039b5dbebb741ab64297ca
BLAKE2b-256 37ebb0eb54ee4aece04d107d8106a8123b2ea75d20cb7caa704e830e45ac5f0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_heatmap-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: rich_heatmap-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 799e2ff90d132f483531a69a3e9a43019353abb8921dadeb98c8c80cc1b16425
MD5 e06c87c0087c26b3d1e59f7561ae6b60
BLAKE2b-256 e9c729f7d2169adbf18f0741eeb0cab4e6e86011f051f84a4bd0d2e75490c6d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rich_heatmap-0.1.2-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