Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Added
- Add pure-Python, dependency-free text renderers `text-utf` (braille/block-char, default) and `text-ascii` (7-bit fallback) that draw an existing `go.Figure` as plain text — `fig.show(renderer="text-utf")` / `"text-ascii"`. Supports scatter/scattergl (lines & markers), bar (honouring `orientation`), and histogram (bins reproduced client-side, numpy-accelerated when available); multi-series bars fan out into sub-columns, unsupported traces and undersized canvases degrade to a one-line note instead of crashing, and output is written as forced UTF-8.
- Add colour text renderers `text-ansi` (24-bit truecolor ANSI escapes) and `text-html` (self-contained class-based HTML fragment) — `fig.show(renderer="text-ansi")` / `"text-html"` — and `heatmap` / `histogram2d` trace support (density shaded via a colorscale-sampled ramp, `histogram2d` binned client-side). Each series is coloured from its own `marker`/`line` colour (normalized from `#hex`, `rgb()/rgba()`, or a CSS name) or the default qualitative palette.


## [6.9.0] - 2026-07-09

Expand Down
7 changes: 7 additions & 0 deletions plotly/io/_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ def show(fig, renderer=None, validate=True, **kwargs):
renderers["sphinx_gallery"] = SphinxGalleryHtmlRenderer()
renderers["sphinx_gallery_png"] = SphinxGalleryOrcaRenderer()

# Text renderers: text-utf (default), text-ascii, and the colour modes
# text-ansi / text-html.
# Registered via a hook so the _text subpackage owns its own renderer classes.
from plotly.io._text import register_text_renderers # noqa: E402

register_text_renderers(renderers)

# Set default renderer
# --------------------
# Version 4 renderer configuration
Expand Down
64 changes: 64 additions & 0 deletions plotly/io/_text/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""Text (Unicode/braille) renderers for ``go.Figure``.

Draws an existing figure as a braille/block-char chart in plain text, as
registered ``plotly.io`` renderer strings (``text-utf`` default, ``text-ascii``;
plus the colour modes ``text-ansi`` and ``text-html``). Pure-Python, **no
external dependency** — the braille + block-char rasterizer is built in here (see
:mod:`~plotly.io._text.rasterizer`).

Architecture ("one grid, many serializers"):

* :mod:`~plotly.io._text.canvas` — Plotly-agnostic drawing surface -> abstract
cell grid.
* :mod:`~plotly.io._text.serializers` — per-mode grid -> string.
* :mod:`~plotly.io._text.adapters` — ``go.Figure`` -> Canvas calls.
* :mod:`~plotly.io._text.renderers` — ``plotly.io`` registration.

This ``__init__`` is the stable public surface of the subpackage;
:mod:`plotly.io._renderers` imports :func:`register_text_renderers` from here.
"""

from __future__ import annotations

from plotly.io._text.canvas import (
Canvas,
Cell,
CellGrid,
CellRole,
Tick,
)
from plotly.io._text.serializers import (
SERIALIZERS,
Serializer,
get_serializer,
register_serializer,
)
from plotly.io._text.adapters import (
ADAPTERS,
AdapterContext,
TraceAdapter,
figure_to_canvas,
get_adapter,
register_adapter,
)
from plotly.io._text.renderers import TextRenderer, register_text_renderers

__all__ = [
"Canvas",
"Cell",
"CellGrid",
"CellRole",
"Tick",
"Serializer",
"SERIALIZERS",
"register_serializer",
"get_serializer",
"ADAPTERS",
"AdapterContext",
"TraceAdapter",
"register_adapter",
"get_adapter",
"figure_to_canvas",
"TextRenderer",
"register_text_renderers",
]
Loading