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

Adding some rounding and error messaging for subplots #4153

Merged
merged 8 commits into from
May 5, 2023
20 changes: 20 additions & 0 deletions packages/python/plotly/plotly/_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,26 @@ def _check_hv_spacing(dimsize, spacing, name, dimvarname, dimname):
else:
y_s = grid[r_spanned][c][1] + spec["b"]
y_e = grid[r][c][1] + heights[-1 - r] - spec["t"]

if y_s > 1.0:
# round for values very close to one
# handles some floating point errors
if y_s < 1.01:
y_s = 1.0
else:
raise Exception(
"A combination of the 'b' values, heights, and "
"number of subplots too large for this subplot gird."
)
if y_e > 1.0:
if y_e < 1.01:
y_e = 1.0
else:
raise Exception(
"A combination of the 't' values, heights, and "
"number of subplots too large for this subplot gird."
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
)

y_domain = [y_s, y_e]

list_of_domains.append(x_domain)
Expand Down