Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Fix] Always respect user-specified color_continuous_scale #5439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
antonymilne wants to merge 4 commits into plotly:main
base: main
Choose a base branch
Loading
from antonymilne:autocolorscale

Conversation

@antonymilne
Copy link
Contributor

@antonymilne antonymilne commented Dec 2, 2025
edited
Loading

Fixes #5433. When a user explicitly provides color_continuous_scale, it should always be respected, even if the template has coloraxis_autocolorscale=True. Previously, the template's autocolorscale setting would override the user's explicit colorscale.

A couple of tests are failing but I'm pretty sure it's not my fault.

Here's the behaviour now. Before this PR, all plots in the above table would have looked the same with the exception of the top left one, where the user-specified color_continuous_scale would have been ignored.

autocolorscale=True autocolorscale=False
01_autocolorscale_True_colorscale_red_yellow_green 02_autocolorscale_False_colorscale_red_yellow_green
03_autocolorscale_True_no_colorscale_sequential 04_autocolorscale_False_no_colorscale_sequential
07_autocolorscale_True_no_colorscale_diverging 08_autocolorscale_False_no_colorscale_diverging

Code PR

  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the code generator and not the generated files.
  • I have added tests or modified existing tests.
  • For a new feature, I have added documentation examples (please see the doc checklist as well).
  • I have added a CHANGELOG entry if changing anything substantial.
  • For a new feature or a change in behavior, I have updated the relevant docstrings in the code.

petar-qb and huong-li-nguyen reacted with thumbs up emoji
...autocolorscale=True
When a user explicitly provides color_continuous_scale, it should always be
respected, even if the template has coloraxis_autocolorscale=True. Previously,
the template's autocolorscale setting would override the user's explicit
colorscale.
The fix tracks whether color_continuous_scale was explicitly provided by the
user (before apply_default_cascade fills it from template/defaults), and only
sets autocolorscale=False when the user explicitly provided a colorscale. This
preserves automatic diverging palette selection when colorscale comes from
template/defaults.
Changes:
- plotly/express/_core.py: Track user_provided_colorscale and conditionally
 set autocolorscale=False only when user explicitly provides colorscale
- plotly/express/_imshow.py: Same fix for imshow() function
Add tests to verify that user-provided color_continuous_scale overrides
template autocolorscale=True, and that template autocolorscale is respected
when user doesn't provide a colorscale.
Changes:
- tests/test_optional/test_px/test_colors.py: Add test_color_continuous_scale_autocolorscale()
- tests/test_optional/test_px/test_imshow.py: Add test_imshow_color_continuous_scale_autocolorscale()
@antonymilne antonymilne marked this pull request as ready for review December 2, 2025 11:51
@antonymilne antonymilne changed the title (削除) Fix: Respect user-specified color_continuous_scale when template has ... (削除ここまで) (追記) [Fix] Always respect user-specified color_continuous_scale (追記ここまで) Dec 2, 2025
Add changelog entry for PR plotly#5439 fixing issue where user-specified
color_continuous_scale was ignored when template had autocolorscale=True.
Copy link
Contributor Author

@emilykl Happy new year to you! 🎉 Do you think you would be able to take a look at this? 🙏

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

Reviewers

@emilykl emilykl Awaiting requested review from emilykl

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug] Plotly express color_continuous_scale ignored when template has autocolorscale=True

AltStyle によって変換されたページ (->オリジナル) /