Skip to content

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

Closed

Description

@oiegorov

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

Activity

  1. jonmmease commented on Aug 4, 2018

    @jonmmease
    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.

  2. added this to the v3.1.1 milestone on Aug 7, 2018
  3. jonmmease commented on Aug 7, 2018

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

  4. Rimesh commented on Oct 5, 2018

    @Rimesh

    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)
    
  5. jonmmease commented on Oct 5, 2018

    @jonmmease
    Contributor

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

  6. jonmmease commented on Oct 5, 2018

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

  7. baasman commented on Apr 15, 2019

    @baasman

    I'm seeing this as well, using 3.5.0

  8. elanter commented on Nov 19, 2019

    @elanter

    Seeing this as well. using 4.2.1

  9. albertsugi-tallridge commented on Feb 21, 2020

    @albertsugi-tallridge

    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!

  10. robroc commented on May 15, 2020

    @robroc

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

  11. nicolaskruchten commented on Jun 9, 2020

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

  12. locked as resolved and limited conversation to collaborators on Jun 9, 2020
  13. nicolaskruchten commented on Jul 16, 2020

    @nicolaskruchten
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions