text_on_color

Contents

text_on_color#

penzai.treescope.arrayviz.arrayviz.text_on_color(text: str, value: float, vmax: float = 1.0, vmin: float | None = None, colormap: list[tuple[int, int, int]] | None = None) ValueColoredTextbox[source]#

Renders some text on colored background, similar to arrayviz coloring.

Parameters:
  • text – Text to display.

  • value – Value to color the background with.

  • vmax – Maximum value for the colormap.

  • vmin – Minimum value for the colormap. Defaults to -vmax.

  • colormap – Explicit colormap to use. If not provided, uses the default diverging colormap if vmin is not provided, or the default sequential colormap if vmin is provided.

Returns:

A rendering of this word, formatted similarly to how this value would be formatted in an array visualization.