Repository navigation
Conversation
When color is continuous, Plotly Express colors marginal traces with the
first entry of color_continuous_scale. For a named scale such as
"Viridis" that entry was the first character of the string ("V"), and
for a list of [position, color] pairs it was the pair itself, both of
which are invalid marker colors. Normalize the scale with
ColorscaleValidator before taking its first color.
Closes plotly#2059
anyingiit
force-pushed
the
fix-px-marginal-named-colorscale-2059
branch
from
October 22, 2026 19:23
572dd47 to
bb9ca36
Compare
This branch has not been deployed
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
Closes #2059
Description of change
With a continuous
color, marginal traces are colored withargs["color_continuous_scale"][0]. For a named scale like"Viridis"that is the first character ('V'), and for a list of[position, color]pairs it is the pair itself, sopx.scatter(..., color=<numeric>, marginal_x="box", color_continuous_scale="Viridis")raises an invalidmarker.colorerror. This PR normalizes the scale withColorscaleValidator(as is already done for the coloraxis) before taking its first color.Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to help projects with open issues. The change was prepared with Claude Code and verified as listed below. If it doesn't fit, or you'd simply rather not take it, please feel free to close it, no hard feelings at all 🙂
Demo
Testing strategy
Added
test_marginal_color_with_continuous_color_scaleintests/test_optional/test_px/test_marginals.py(named, lowercase, reversed_r, list of colors and list of pairs × histogram/box/violin/rug). 16 of its 20 cases fail onmain(the list-of-colors cases already worked) and all pass with this change.python -m pytest tests/test_optional/test_px --ignore=.../test_imshow.py --ignore=.../test_trendline.py: 1083 passed, 3 failed (test_render_mode, which needsstatsmodels, not installed locally)ruff format --check .andruff checkon the changed files: cleanGuidelines