Repository navigation
make_subplots crashes if vertical_spacing is set #2273
Copy link
Copy link
Closed
Description
BUG REPORT
plotly version: 4.5.4
python version: 3.6.9
Calling make_subplots with the following parameter will make it crash.
figSubplots = make_subplots(
rows=12, cols=1, shared_xaxes=True, vertical_spacing=0.1
)
With rows = 11 it still works. Between 11 rows there are 10 spacings, it means that the sum of the all spacings is 10 x 0.1 = 1.0. I tried some combination. Whenever this sum is over 1.0 the function crashes.
I assume that vertical_spacing leads to some kind of overflow.
The traceback shows the following:
Traceback (most recent call last):
__File "./plot_results.py", line 50, in <module>
rows=rows, cols=1, shared_xaxes=True, vertical_spacing=0.1
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/subplots.py", line 685, in make_subplots
layout, subplot_type, secondary_y, x_domain, y_domain, max_subplot_ids
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/subplots.py", line 1057, in _init_subplot
layout, secondary_y, x_domain, y_domain, max_subplot_ids
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/subplots.py", line 921, in _init_subplot_xy
layout[yaxis_name] = y_axis
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/basedatatypes.py", line 4437, in __setitem__
super(BaseLayoutHierarchyType, self).__setitem__(prop, value)
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/basedatatypes.py", line 3482, in __setitem__
self._set_compound_prop(prop, value)
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/basedatatypes.py", line 3836, in _set_compound_prop
val = validator.validate_coerce(val, skip_invalid=self._skip_invalid)
File "/home/kerese/.local/lib/python3.6/site-packages/_plotly_utils/basevalidators.py", line 2444, in validate_coerce
v = self.data_class(v, skip_invalid=skip_invalid)
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/graph_objs/layout/__init__.py", line 3055, in __init__
self["domain"] = domain if domain is not None else _v
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/basedatatypes.py", line 3490, in __setitem__
self._set_prop(prop, value)
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/basedatatypes.py", line 3777, in _set_prop
raise err
File "/home/kerese/.local/lib/python3.6/site-packages/plotly/basedatatypes.py", line 3772, in _set_prop
val = validator.validate_coerce(val)
File "/home/kerese/.local/lib/python3.6/site-packages/_plotly_utils/basevalidators.py", line 2172, in validate_coerce
v[i] = validator.validate_coerce(el)
File "/home/kerese/.local/lib/python3.6/site-packages/_plotly_utils/basevalidators.py", line 787, in validate_coerce
self.raise_invalid_val(v)
File "/home/kerese/.local/lib/python3.6/site-packages/_plotly_utils/basevalidators.py", line 283, in raise_invalid_val
valid_clr_desc=self.description(),
ValueError:
Invalid value of type 'builtins.float' received for the 'domain[0]' property of layout.yaxis
Received value: 1.0083333333333333
The 'domain[0]' property is a number and may be specified as:
- An int or float in the interval [0, 1]__
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
empet commentedon Mar 13, 2020
Plotly places all subplots within a square
[0,1] x [0,1], and then maps this square onto the plot window, defined by your layout settings. If yourvertical_spacing=0.1then 11*0.1=1.1 is greater than the square height. That's why you got the displayed errorHere is an example that can suggest how to tune your
vertical_spacing, andgo.layout.width,go.layout.heightto get your figure:nicolaskruchten commentedon Mar 13, 2020
Thanks @empet! We should modify
make_subplotsto provide a clearer error message for this, though.gvwilson commentedon Jun 14, 2024
Hi - we are currently trying to tidy up Plotly's public repositories to help us focus our efforts on things that will help users most. Since this issue has been sitting for several years, I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our backlog. Thanks for your help - @gvwilson