autosize not working as expected in plotly.offline.plot
See original GitHub issueThe height of plots stored in html via plotly.offline.plot
is set to 450px when height is not specified (at least in my test).
Example:
import numpy as np
import pandas as pd
import plotly
from plotly import graph_objs as go
from plotly.offline import plot
N = 1000
df = pd.DataFrame({
't': np.random.random(N),
'x': np.random.random(N),
'y': np.random.random(N)
})
traces = [
go.Scatter3d(
x=df['x'],
y=df['y'],
z=df['t'],
mode='markers',
marker=dict(size=1)
)
]
layout = go.Layout(
autosize=True,
scene=go.layout.Scene(
xaxis=go.layout.scene.XAxis(title='X'),
yaxis=go.layout.scene.YAxis(title='Y'),
zaxis=go.layout.scene.ZAxis(title='Time'),
)
)
fig = go.Figure(data=traces, layout=layout)
filename = f"demo.html"
plotly.offline.plot(fig, filename=filename, auto_open=False)
The picture below shows the entire browser page in Firefox 66.0.3
on macOS High Sierra 10.13.6
. The file looks the same in Chrome 73.0.3683.103
. I am using plotly 3.8.0
on Python 3.7
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Plot sizing problems - plotly.js - Plotly Community Forum
Setting autosize: true stops the width being correct and causes the height to expand, breaking the layout. Removing the two Plotly.
Read more >Python Plotly: autosize table plot - Stack Overflow
I know I can make the height of the layout dependent on the number of rows but this doesn't solve the problem because...
Read more >[Solved]-Python Plotly: autosize table plot-Pandas,Python
import pandas as pd import plotly.graph_objs as go import plotly.offline as py py.offline.init_notebook_mode() import numpy as np df = pd.
Read more >Weird behavior with plotly chart — DataTables forums
The plotly charts in this datatable render properly upon showing all ... src="https://cdn.plot.ly/plotly-1.42.5.min.js"></script> <script ...
Read more >plotly package — 5.11.0 documentation - Plotly Help Center
This can cause the plot to appear to stutter as the three updates are applied incrementally. We can avoid this problem by performing...
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
@jonmmease Confirmed! The problem disappears with the build you linked! Thanks for the quick response!
@marcotama and @ijustmadethisforplotly, could you give the dev build in #1525 a try and confirm that it takes care of the problems you’re seeing?
Installation instructions are in https://github.com/plotly/plotly.py/pull/1525#issuecomment-484235115. Thanks!