plotly / plotly/plotly.py

Certain padding values cause plots to overtake all other subplots

Open
#4,144 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

Related to #4124 there is a set of padding values that will produce strange behavior such that a single subplot takes over all others.

Some setup:

import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
line_x = np.arange(10)
line_y = line_x**2

What works:

n_subplots = 6

full_fig = make_subplots(
    rows=n_subplots,
    cols=1,
)

for row_idx in range(1, n_subplots+1):
    full_fig.add_trace(go.Scatter(
            x=line_x,
            y=line_y,
            showlegend=False,
        ), row=row_idx, col=1)

This produces 6 different subplots of the same line.

What doesn't work:

line_x = np.arange(10)
line_y = line_x**2

n_subplots = 8
padding_size = 0.1

row_heights = [0.1]*n_subplots

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

full_fig = make_subplots(
    rows=n_subplots,
    cols=1,
    row_heights=row_heights,
    specs=specs,
)

for row_idx in range(1, n_subplots+1):
    full_fig.add_trace(go.Scatter(
            x=line_x,
            y=line_y,
            showlegend=False,
        ), row=row_idx, col=1)

Adding the padding and row heights now generates only a single plot.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided make_subplots examples and compare the six-row case with the eight-row case using row_heights and specs padding. Trace how make_subplots handles row heights and top/bottom padding, then verify the fix against the reproduced configuration. Done means all eight subplots render separately rather than one subplot taking over.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.