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'.
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.
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!
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)
Hi @Rimesh, thanks for letting us know. Could you add the error message that you're seeing?
@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!
I'm seeing this as well, using 3.5.0
Seeing this as well. using 4.2.1
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!
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).
@albertsugi-tallridge you're encountering bug https://github.com/plotly/plotly.py/issues/2556 and you can get around it by reducing your vertical_spacing
@robroc yours is more akin to https://github.com/plotly/plotly.py/issues/2026
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
Most helpful comment
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!