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

Uploaded Python 3

File details

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

File metadata

  • Download URL: rich_heatmap-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 9a210b834dbcbcc4e642699564ef9ae51b51ee0baa62e87d8899c2a2e1288f27
MD5 5e96b2e3cede6a86a5c8914a78f072a6
BLAKE2b-256 1b5128b8f1be968acebd76c7d875002ded672bcd2b1f2d0d5c63b0f52ebb6c51

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rich_heatmap-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b59d55d71a2536b419eb036140fad1fac1c520dcf3af66e3223cde2351fea47
MD5 bcd6faf17315c5a5507947b44a49fbfe
BLAKE2b-256 db54f375a5db713e87136b967a576108663b508707d02f43834d97bccf9724b2

See more details on using hashes here.

Provenance

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