Plotly Express template margin issue
See original GitHub issueHello,
If I use px for a scatter plot with margin right and bottom set to 0, I get some strange margin on the right anyway
fig = px.scatter(data, x='x', y='y')
fig.update(layout = go.Layout(margin=dict(t=0,r=0,b=40,l=40)))
The same works fine using
fig = go.Figure()
If I try to set a default layout
import plotly.io as pio # to set mine plot layout
pio.templates['mine'] = pio.to_templated(go.Figure().update_layout(plot_bgcolor='rgba(200,200,200,1)',legend=dict(orientation="h",y=1.1, x=.5, xanchor='center'),margin=dict(t=0,r=0,b=40,l=40))).layout.template
pio.templates.default = 'mine'
It works fine for
fig = go.Figure()
but for
fig = px.scatter(data, x='x', y='y')
fig.show()
I get large padding on top, and the same weird little bit on the right.
I refer to the margin on the right as weird because when I do
fig.layout
I only se
'margin': {'t': 60},
Even if I do
fig.update(layout = go.Layout(margin=dict(t=0,r=0,b=40,l=40)))
afterwards, I still have the weird right margin. No the same issue with go.Figure()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Styling plotly express figures in Python
Every Plotly Express function accepts the following arguments: title to set the figure title; width and height to set the figure dimensions; template...
Read more >Removing the white border around Plotly chart in Python
import pandas as pd import numpy as np import plotly.express as px df ... ( margin=dict(l=0,r=0,b=0,t=0), paper_bgcolor="Black" ) fig.show().
Read more >How to change figure size in Plotly in Python - GeeksforGeeks
It can also be achieved using different methods for different use cases. Changing Height, Width, & Margins with Plotly Express. We will now...
Read more >Plotly Tutorial for Everyone | Kaggle
Pie Chart using Plotly Express; 10. Bubble Chart; 11. Area Plot; 12. Tables and Figure Factory Tables; 13. Color Scales in Plotly Express;...
Read more >Enhance Your Plotly Express Scatter Plot With Marginal Plots
Plotly Express Scatter Plot of well log data illustrating marginal ... Marginal plots are mini plots that can be attached to the margins...
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
@nicolaskruchten thanks for the hint - it is indeed xaxis.domain. Unfortunately setting this to [0,1] in my template is ignored by plotly.express, I have to use fig.update_layout(xaxis=dict(domain=[0,1])) after every figure…
I will try put a MWE for the title issue soon
Yes, the domains are set explicitly from within PX, so it will never respect the template settings.
That said, @jonmmease what’s the reasoning for having the single-subplot case have a domain that’s not
[0,1]
? Is this something I had in the pre-make_subplots
version that got carried over or is it something thatmake_subplots
does or…?