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.

tools.make_subplots with colspan/rowspan fails when using sharex/sharey

See original GitHub issue

Hi, i am trying to create subplots with colspan/rowspan attribute and shared_xaxes using the code below (Plotly 3.3). As soon as i use the shared_xaxes=True parameter, the code fails with the error message:

Exception: Something went wrong. An axis object for (2,4) subplot cell got deleted.

Example code:

from plotly import tools
import plotly
import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Scatter(
    x=[0, 1, 2],
    y=[10, 11, 12]
)
trace2 = go.Scatter(
    x=[2, 3, 4],
    y=[100, 110, 120],
)
trace3 = go.Scatter(
    x=[2, 3, 4],
    y=[100, 110, 120],
)

fig = tools.make_subplots(rows=3, cols=4, specs=[[{'colspan':3}, None, None, None], 
                                                [{'rowspan':2, 'colspan':3}, None, None, {'rowspan':2}], 
                                                [None, None, None, None]],
                          shared_xaxes=True, shared_yaxes=True,
                          vertical_spacing=0.001)

print(fig['layout'])

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 2, 1)
fig.append_trace(trace3, 2, 4)

print(fig['layout'])

fig['layout'].update(height=600, width=600, title='Stacked Subplots with Shared X-Axes')
plotly.offline.iplot(fig, filename='test')

Cheers, Georg

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
clariacommented, Sep 29, 2018

@empet Nope. Even adding a vertically aligned subplot+trace does not help:

from plotly import tools
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.io as pio


trace1 = go.Scatter(
    x=[0, 1, 2],
    y=[10, 11, 12]
)
trace2 = go.Scatter(
    x=[0, 1, 2],
    y=[100, 110, 120],
)
trace3 = go.Scatter(
    x=[0, 1, 2],
    y=[100, 110, 120],
)
trace4 = go.Scatter(
    x=[0, 1, 2],
    y=[100, 110, 120],
)
trace5 = go.Scatter(
    x=[0, 1, 2],
    y=[100, 110, 120],
)

fig = tools.make_subplots(rows=5, cols=4, specs=[[{'colspan':3}, None, None, None], 
                                                 [{'rowspan':2, 'colspan':3}, None, None, {'rowspan':2}], 
                                                 [None, None, None, None],
                                                 [{'rowspan':2, 'colspan':3}, None, None, {'rowspan':2}], 
                                                 [None, None, None, None],
                                                 ],
                          shared_xaxes=True, shared_yaxes=True,
                          vertical_spacing=0.001)

print(fig['layout'])

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 2, 1)
fig.append_trace(trace3, 2, 4)
fig.append_trace(trace4, 4, 1)
fig.append_trace(trace5, 4, 4)

print(fig['layout'])

fig['layout'].update(height=600, width=600, title='Stacked Subplots with Shared X-Axes')
plotly.offline.iplot(fig, filename='test')

0reactions
empetcommented, Oct 2, 2018

@jonmmease this issue can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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