Add dependency-free text renderers (text-utf/ascii/ansi/html) for go.Figure#5670
Draft
T4rk1n wants to merge 1 commit into
Draft
Add dependency-free text renderers (text-utf/ascii/ansi/html) for go.Figure#5670T4rk1n wants to merge 1 commit into
T4rk1n wants to merge 1 commit into
Conversation
…/html) Add four pure-Python, dependency-free plotly.io renderers that draw an existing go.Figure as plain text: - text-utf — braille/block-char (default) - text-ascii — 7-bit ASCII fallback - text-ansi — 24-bit truecolor ANSI escapes - text-html — self-contained class-based HTML fragment Usable via fig.show(renderer="text-utf") (etc.). Supports scatter/scattergl (lines & markers), bar (honouring orientation, with grouped fan-out), histogram, and heatmap/histogram2d (colorscale-sampled density shading). Per-series colour is taken from each trace's marker/line colour or the default qualitative palette. Unsupported traces and undersized canvases degrade to a one-line note instead of raising. Adds unit tests and a CHANGELOG entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
No tracking issue yet — happy to open a feature issue if preferred.
Description of change
Adds four pure-Python, dependency-free
plotly.iorenderers that draw an existinggo.Figureas plain text:text-utf(braille/block-char, default) andtext-ascii(7-bit fallback), plus colour variantstext-ansi(24-bit truecolor ANSI) andtext-html(self-contained class-based HTML). Use viafig.show(renderer="text-utf").Demo
Testing strategy
Adds unit tests under
plotly/io/_text/tests/covering the drawing canvas and per-mode serializers, the per-trace adapters and renderer registration, and the colour + heatmap paths (golden-output comparisons; numpy-accelerated branches exercised). All 103 tests pass locally.Additional information
Design is "one grid, many serializers": a Plotly-agnostic cell-grid canvas, per-mode serializers (one per
text-*output), and per-trace adapters that turn ago.Figureinto canvas calls. Supported traces: scatter/scattergl (lines & markers), bar (honouringorientation, with grouped fan-out), histogram, and heatmap/histogram2d (density shaded via a colorscale-sampled ramp). Per-series colour is normalized from#hex/rgb()/rgba()/ CSS name, falling back to the default qualitative palette. Unsupported traces and undersized canvases degrade to a one-line note rather than raising. Output is written as forced UTF-8.Guidelines