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.

autosize not working as expected in plotly.offline.plot

See original GitHub issue

The 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.

Screen Shot 2019-04-16 at 12 04 42 pm

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
marcotamacommented, Apr 18, 2019

@jonmmease Confirmed! The problem disappears with the build you linked! Thanks for the quick response!

0reactions
jonmmeasecommented, Apr 17, 2019

@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!

Read more comments on GitHub >

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

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