Skip to content

go.Table appearance ignores the deafult PX template #1869

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

Closed
joelostblom opened this issue Nov 4, 2019 · 5 comments
Closed

go.Table appearance ignores the deafult PX template #1869

joelostblom opened this issue Nov 4, 2019 · 5 comments

Comments

@joelostblom
Copy link
Contributor

go.Table seems to be fixed at using the plotly template, and using PX to change to other templates has no effect. Updating the plotly template even after switching to another PX default template changes the appearance of the table.

I couldn't figure out if the template go.Table is using is set at a location that is not overwritten when changing the PX default template, or if the plotly template is hardcoded to always be used within the table function.

I appreciate that go.Table is not a PX function, but since it seemingly is reading from a default template somewhere and the PX templates all specify Table colors, it would be useful if the Table appearance would change when the default PX template changes.

Here is an example of what I mean, note the comments.

import plotly.express as px
import plotly.io as pio
import plotly.graph_objects as go

# Plotly template
fig1 = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
                cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))]) 
fig1.show()

# Changing to ggplot2 doesn't anything
px.defaults.template = 'ggplot2'
fig2 = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
                cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))]) 
fig2.show()

# Updating the plotly template shows that go.Table is reading from the 
# plotly template rather than ignoring templates altogether.
pio.templates['plotly'].data.table[0].cells.fill.color = 'orange'
fig3 = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
                cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))]) 
fig3.show()

Fig1
image

Fig2
image

Fig3
image

@joelostblom joelostblom mentioned this issue Nov 4, 2019
6 tasks
@nicolaskruchten
Copy link
Contributor

Right, the PX templates apply only to the PX functions.

@nicolaskruchten
Copy link
Contributor

If you want to set a default template plotly-wide, the way to do it is to set pio.templates.default. px.defaults.template is sort of a "legacy" PX-only setting that lets you set a template when using PX without having to import anything else, following the "one import only gets you the whole thing" philosophy of PX.

@joelostblom
Copy link
Contributor Author

Thanks for clarifying. So pio.templates.default will affect both px and go figures, unless px.defaults.template is set which would leave px figures unaffected by pio.templates.default. On the other hand, px.defaults.template always affects px figures, but never go figures. I noticed that this is explained well in the docs already.

When you say it is a legacy option, do you mean it might go away or be changed soon? Would it make sense to have px.defaults.template as a shortcut for pio.templates.default which changes both px and go figures while not requiring to import plotly.io or would there be negative side effects / no real advantage from that setup?

@nicolaskruchten
Copy link
Contributor

Legacy in this context means we added it in the past for possibly-dubious reasons, but removing or changing its behaviour now would be considered a breaking change that might break some code in the wild and so we're not willing to do that in the near future :) We can talk about it for v5!

@gvwilson
Copy link
Contributor

Hi - we are currently trying to tidy up Plotly's public repositories to help us focus our efforts on things that will help users most. Since this issue has been sitting for several years, I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our backlog. Thanks for your help - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants