[Fix] Support trace-specific color sequences in Plotly Express via templates by antonymilne · Pull Request #5437 · plotly/plotly.py
added 5 commits
- Check template.data.<trace_type> for marker.color or line.color before falling back to template.layout.colorway - Handle timeline special case (maps to bar trace type) - Use marker colors first, fall back to line colors if no markers found - Fixes issue plotly#5416
- Modify apply_default_cascade to check template.data.<trace_type> for marker.color or line.color - Fallback to template.layout.colorway if trace-specific colors not found - Add comprehensive tests for trace-specific color sequences - Handle timeline special case (maps to bar trace type) - Follow existing patterns for symbol_sequence and line_dash_sequence Fixes plotly#5416
- Modify apply_default_cascade to read colors from template.data.<trace_type> - Prioritize trace-specific colors over layout.colorway - Add special case for timeline constructor (maps to bar trace type) - Add comprehensive tests for trace-specific color sequences - Test trace type isolation, fallback behavior, and timeline special case
antonymilne
changed the title
Trace-specific colors
[Fix] Support trace-specific color sequences in Plotly Express via templates
- Make constructor parameter required (was optional with None default) - Refactor trace-specific color extraction to only assign when colors are found - Improve code clarity by checking for non-empty color list before assignment
- Remove redundant check that was setting color_discrete_sequence to None - The check is unnecessary since we only assign trace_specific_colors when any() is True - Fallback logic to layout.colorway and qualitative.D3 remains intact
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