question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plotly Express does not play well with templates

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, May 10, 2019

@Batalex this is now released! You should be able to set pio.templates.default and plotly_express will grab the colors from there, and it also respects px.defaults.template as well as the template kwarg.

1reaction
nicolaskruchtencommented, May 8, 2019

It would be nice if there was a logical correspondence between the px template and a user-specified template, so any px default parameter set to None has a template fallback.

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.

there are a lot of places [the template] can be specified

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 as layout.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 from template.layout.colorway and template.layout.colorscale.sequential and call it a day 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found