Plotly Express does not play well with templates
See original GitHub issueHi,
I noticed that Plotly Express is quite opinionated with some default values, which unfortunately do not play well with template’s defined values such as graph height or color scale.
For example, I would expect px.histogram(some_dataframe, template="seaborn")
to use the seaborn color palette.
Is there any plans to pick up default values in the active template instead?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Theming and templates in Python - Plotly
Specifying themes in Plotly Express All Plotly Express functions accept a template argument that can be set to the name of a registered...
Read more >Plotly add_hline() doesn't work with simple_white template
It works perfectly fine so long as I do not use the simple_white template. The MWE is here: import plotly.express as px df...
Read more >Visualization with Plotly.Express: Comprehensive guide
A detailed guide on how to create many visualizations with Plotly Express with layout styling, interactivity, animations, and many chart ...
Read more >Module 7 (Plotly Express and Jinja2 Templates) - YouTube
Your browser can't play this video. ... Web Based Dashboard Programming in Python - Module 7 ( Plotly Express and Jinja2 Templates )....
Read more >4 Ways To Improve Your Graphs Using Plotly
There are multiple ways to do it. The lowest-level approach is to use Python dictionaries, and the highest-level one is using the Plotly...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Batalex this is now released! You should be able to set
pio.templates.default
andplotly_express
will grab the colors from there, and it also respectspx.defaults.template
as well as thetemplate
kwarg.The
px
defaults are very few: color scale and sequence, symbol/dash sequences and dimensions. Everything else is use-specified. Among those, color scale&sequence and width/height are the only ones that are present in the template.Actually “[the template]” is not what I meant, I meant the colors 😃 In a template, we have color scales and sequences in a few places in
layout
such aslayout.colorway
,layout.piecolorway
,layout.sunburstcolorway
,layout.colorscale.sequential
,layout.colorscale.sequentialminus
,layout.colorscale.diverging
but also on a per-trace-type basis: a template can specify one colorscale for scatter and another for heatmaps, and it can also specify that the first scatter is one color and the second is another, at which point I think that scatter traces will end up alternating between the two colors. So… yeah, there are a lot of ways to specify colors in a template.All that said,
px
could just ignore most of that complexity and try to read fromtemplate.layout.colorway
andtemplate.layout.colorscale.sequential
and call it a day 😃