Skip to content

Fix static-export legend and colorbar text ignoring theme text_color#86

Open
FarhanAliRaza wants to merge 2 commits into
mainfrom
fix/export-legend-theme-text-color
Open

Fix static-export legend and colorbar text ignoring theme text_color#86
FarhanAliRaza wants to merge 2 commits into
mainfrom
fix/export-legend-theme-text-color

Conversation

@FarhanAliRaza

Copy link
Copy Markdown
Contributor

Problem

On a dark-themed figure (xy.theme(text_color="#ffffff", ...)), the browser client renders legend text with var(--chart-text), but both static exporters painted legend entries, legend titles, and colorbar labels/ticks with the hard-coded light-mode constant rgba(32,32,32,0.85) — so legend text effectively disappears in exported PNG/SVG while remaining visible in the notebook:

Surface Legend text color
Browser client theme text_color (visible)
SVG export hard-coded dark gray (invisible on dark)
Native PNG export hard-coded dark gray (invisible on dark)

Fix

Thread the theme-resolved default_text (already used for titles, axis labels, and tick labels) through:

  • _svg.py: _legend() and _colorbar()
  • _raster.py: _emit_legend() and _emit_colorbar()

Figures without a theme keep the existing light-mode default, byte-for-byte.

Tests

  • test_svg_legend_text_honors_theme_text_color: themed SVG legend entries + title use the theme color; unthemed keeps rgba(32,32,32,0.85).
  • test_raster_legend_text_honors_theme_text_color: pixel-level check on the native rasterizer — red reserved for text_color, so red pixels can only come from legend text.

pre-commit run --all-files, ruff check/format --check, and both export suites (54 tests) pass.

The SVG and native-PNG exporters painted legend entries, legend titles,
and colorbar labels/ticks with the hard-coded light-mode text color
(rgba(32,32,32,0.85)), so on dark-themed figures the legend text was
nearly invisible in exports while the browser client rendered it with
var(--chart-text). Thread the theme-resolved default text color (already
used for titles, axis labels, and tick labels) through _legend/_colorbar
in _svg.py and _emit_legend/_emit_colorbar in _raster.py. Untouched
default: figures without a theme keep the existing light-mode color.
…me-text-color

# Conflicts:
#	python/xy/_raster.py
@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 94 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing fix/export-legend-theme-text-color (8b8197c) with main (7ab6028)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant