Skip to content
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

plotly.tools.make_subplots() breaks down if rows>=100 #1031

Closed
oiegorov opened this issue Jun 12, 2018 · 11 comments
Closed

plotly.tools.make_subplots() breaks down if rows>=100 #1031

oiegorov opened this issue Jun 12, 2018 · 11 comments
Labels
bug something broken
Milestone

Comments

@oiegorov
Copy link

For some reason all data in subplots get jumbled up if 'rows' is 100 or higher. It works fine for rows=99. Here is an example code:

N = 100
v_space = 0

fig = tools.make_subplots(
    rows=N,
    cols=1,
    vertical_spacing=v_space
)

for i in range(N):
    x1 = 1
    y1 = 1
    trace = go.Scatter(
        x=[x1],
        y=[y1],
    )
    fig.append_trace(trace, i + 1, 1)

fig['layout'].update(height=N * 200)
py.iplot(fig)

If vertical_spacing is not zero and fig['layout'].update(height=N*(200+vertical_spacing)), it breaks down for smaller values of 'rows'.

@jonmmease
Copy link
Contributor

Thanks for the report @oiegorov,

I think this is the same issue that was brought up in the forums here: https://community.plot.ly/t/domain-issues-with-multiple-subplots/12282/2

With plotly.py version 3 we get a more informative error (instead of the jumbled result you were seeing)

ValueError: 
    Invalid value of type 'builtins.float' received for the 'domain[1]' property of layout.yaxis
        Received value: 1.0000000000000007

    The 'domain[1]' property is a number and may be specified as:
      - An int or float in the interval [0, 1]

Looks like a numerical precision error. We probably just need a min(1.0, val) somewhere.

@jonmmease
Copy link
Contributor

Hi @oiegorov ,

I just pushed out release candidates for plotly.py 3.1.1 and plotlywidget 0.2.1. Installation instructions for the release candidates are at https://github.com/plotly/plotly.py/blob/bc1d4d188ab999cd9c21e3a7908729f156bc200f/README.md.

If you have a chance to confirm that this issue is resolved in the release candidate that would be awesome!

@Rimesh
Copy link

Rimesh commented Oct 5, 2018

Hi @jonmmease ,

It looks like the issue is still not resolved.
make_subplots breaks down at rows > 70

Here is an example code:

from plotly.offline import plot
import plotly.graph_objs as go
from plotly import tools

X = list(range(50))
Y = list(range(50))

n_rows = 70 # make_subplots breaks down if rows > 70

fig = tools.make_subplots(rows=n_rows, cols=1)
fig['layout'].update(height=5000, width=1000)

for i in range(n_rows):
	trace = go.Scatter(x = X, y = Y)
	fig.append_trace(trace, i+1, 1)

plot(fig)

@jonmmease
Copy link
Contributor

Hi @Rimesh, thanks for letting us know. Could you add the error message that you're seeing?

@jonmmease
Copy link
Contributor

@Rimesh, I gave it a try and I don't see an error message, but I do see that the subplot y-axes start overlapping. If this is what you're seeing as well, could you open a new issue? I think this is a different underlying issue. Thanks!

@baasman
Copy link

baasman commented Apr 15, 2019

I'm seeing this as well, using 3.5.0

@elanter
Copy link

elanter commented Nov 19, 2019

Seeing this as well. using 4.2.1

@albertsugi-tallridge
Copy link

albertsugi-tallridge commented Feb 21, 2020

Hi @jonmmease , I am using plotly 4.5.1 and am getting this error too as i tried creating a subplot with 63 rows. it gives an error if the row is bigger than 58 rows.

Here is the code:
fig = make_subplots(rows=63, cols=1, shared_xaxes=True, vertical_spacing=0.02) size = len(asinhourlydict) xvalues = ["12am", "1am", "2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm", "2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm" ] for key,value in asinhourlydict.items(): fig.add_trace(go.Bar(x=xvalues,y=value),row=size,col= 1) fig.update_yaxes(title_text=key, row=size, col=1) size = size -1 fig.write_html('violationbarchart.html', config={ "displayModeBar" : False} )

and here is the error:

ValueError: Invalid value of type 'builtins.float' received for the 'domain[0]' property of layout.yaxis Received value: 1.0038095238095237 The 'domain[0]' property is a number and may be specified as: - An int or float in the interval [0, 1]

Is there a way to fix this? Or is it my code that have bugs? Thanks in advance!

@robroc
Copy link

robroc commented May 15, 2020

I'm having this issue with Plotly Express in Plotly 4.7.1, when trying to create faceted subplots with 92 plots (at 6 per row it's 16 rows).

@nicolaskruchten
Copy link
Contributor

@albertsugi-tallridge you're encountering bug #2556 and you can get around it by reducing your vertical_spacing

@robroc yours is more akin to #2026

@plotly plotly locked as resolved and limited conversation to collaborators Jun 9, 2020
@nicolaskruchten
Copy link
Contributor

In Plotly Express you can now (as of version 4.9) avoid this problem by using facet_row_spacing and facet_col_spacing https://plotly.com/python/facet-plots/#controlling-facet-spacing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

8 participants