Skip to content

Domain error uncaught when using padding and row heights #4124

Closed
@stephenpardy

Description

@stephenpardy

I am using plotly 5.13.1 on an M1 Mac.

I have found an issue where setting the padding and row heights of multiple subplots will generate an error

ValueError: 
    Invalid value of type 'builtins.float' received for the 'domain[0]' property of layout.yaxis
        Received value: 1.0078125

    The 'domain[0]' property is a number and may be specified as:
      - An int or float in the interval [0, 1]

This error has been previously reported when making many subplots. See #2556, #2026, #2273, #1216, #1121, #1031. In those cases the issue was related to vertical_spacing or other parameters, and an explicit error is now raised when users try to set spacings that would crash the plotting.

In my case, I am setting the padding (and/or row heights) and get the original domain error.

Reproducible example:

from plotly.subplots import make_subplots

n_subplots = 8
padding_size = 0.2

specs = []
for _ in range(n_subplots):
    specs.append([{'b': padding_size/2., 't': padding_size/2.}])
    
fig = make_subplots(rows=n_subplots, specs=specs)

fig

I see in previous issues that the grid is in a square of [0, 1], [0, 1], but the padding sizes here only cause the error when the number of rows is > 7 which doesn't seem to follow that pattern.

I would love it if we could get a similarly descriptive error message for these cases and some guidance on where exactly the issue is coming from so that I can work on a workaround for our plotting code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions