plotly / plotly/plotly.py

[BUG]: `vertical_spacing` argument for `make_subplots` should leave space for subplot titles

Đang mở
#5,606 4 bình luận 0 reaction 1 người được giao Xem trên GitHub

@SharadhNaidu đang làm issue này rồi.

Từ ngày 10/6/2026.

bug P2 size: 5
Ngôn ngữ chính
Python
Star
18.8k
Fork
2.8k
Merge trung bình
16 giờ 26 phút
Pull request đã merge (30 ngày)
21

Mô tả

Description

Setting the vertical_spacing argument of make_subplots to a small value, while also passing subplot_titles, results in a really ugly chart where the subplot titles overlap the subplots themselves.

Ideally vertical_spacing should take titles into account, and control the spacing between the top of the title and the bottom of the subplot above.

We obviously don't know the exact size of the title text, but something like font size * 1.75 should be approximately the right amount of space for a single-line title.

However we need to see whether this requires changes to Plotly.js, since axis.domain only supports units of plot fraction, not sure if there is a way to shift it by a certain number of pixels.

Screenshots/Video
Image
Steps to reproduce
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import random

fig1 = make_subplots(
        rows=6, cols=1,
        shared_xaxes=True,
        vertical_spacing=0.02,
        row_heights=[0.35, 0.13, 0.13, 0.13, 0.13, 0.13],
        subplot_titles=['Heart Rate Variability', 'Walking', 'Cycling', 'Hiking', 'Other', 'Pilates']
    )
for i in range(6):
    fig1.add_trace(
        go.Scatter(x=[0,1,2], y=[random.randint(0, 10) for _ in range(3)]),
        row=i+1,
        col=1
    )
fig1.show()

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.