GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Keep axis-spanning shapes on an empty subplot selected by row and col by LukeTheoJohnson · Pull Request #5871 · plotly/plotly.py

Conversation

@LukeTheoJohnson

@LukeTheoJohnson LukeTheoJohnson commented Nov 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Link to issue

Closes #5136

Description of change

Change add_hline, add_vline, add_hrect and add_vrect to ignore exclude_empty_subplots when row and col select a single subplot, as suggested here.

Demo

from plotly.subplots import make_subplots

fig = make_subplots(rows=1, cols=1)
fig.add_hline(y=0.5)
print(len(fig.layout.shapes))

fig = make_subplots(rows=2, cols=2)
fig.add_hline(y=0.5, row=2, col=1)
print(len(fig.layout.shapes))

fig = make_subplots(rows=2, cols=2)
fig.add_hline(y=0.5)
print(len(fig.layout.shapes))

On main this prints 0 0 0. With this change it prints 1 1 0.

Testing strategy

New tests in test_axis_span_shapes.py run all four methods against a single subplot, an explicit row/col, col="all" on a one-column grid and list selections, plus a grid where the other cell is None, an empty secondary axis and an empty facet. These 19 fail on main and pass with this change. Two more check that several empty subplots are still skipped, and one that an out-of-range row keeps its IndexError.

tests/test_core plus test_px, test_figure_factory, test_subplots and test_autoshapes under tests/test_optional have the same failures as main. ruff check and ruff format --check are clean on the changed files, and codegen output matches the committed _figure.py and _figurewidget.py.

Additional information (optional)

Before, the shape was dropped without warning if the selected subplot was empty, even when it was the only one or was requested by row and col. The workaround was to pass exclude_empty_subplots=False. Selections covering several subplots still skip empty ones.

An explicit exclude_empty_subplots=True is also ignored for a single subplot, because it can't be told apart from the default. Keeping it would mean changing the default to a sentinel.

An explicit row/col on a blank facet_col_wrap cell now draws there too.

I used Claude Code to help write this change. I've reviewed and tested it myself.

Guidelines

  • I have reviewed the pull request guidelines and the Code of Conduct and confirm that this PR follows them.
  • I have added an entry to the changelog if needed (not required for documentation PRs).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
LukeTheoJohnson added 2 commits November 6, 2026 21:36
@LukeTheoJohnson
Keep axis-spanning shapes on an empty subplot selected by row and col
c56b97e
@LukeTheoJohnson
Add PR number to changelog entry
076cd1c
@LukeTheoJohnson
LukeTheoJohnson marked this pull request as ready for review November 6, 2026 09:00
@KoolADE85
KoolADE85 self-requested a review November 9, 2026 20:53
@KoolADE85 KoolADE85 self-assigned this Nov 9, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@KoolADE85 KoolADE85 Awaiting requested review from KoolADE85

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@KoolADE85 KoolADE85

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

add_hline not working for make_subplots if not populated

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@LukeTheoJohnson @KoolADE85
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.