Skip to content

Respect facet_row_spacing=0 and facet_col_spacing=0 in Plotly Express - #5881

Open
rishi02102017 wants to merge 1 commit into
plotly:mainfrom
rishi02102017:px-facet-spacing-zero
Open

rishi02102017 wants to merge 1 commit into
plotly:mainfrom
rishi02102017:px-facet-spacing-zero

Conversation

@rishi02102017

Copy link
Copy Markdown

Link to issue

Closes #5880

Description of change

Plotly Express fell back to the default facet spacing whenever facet_row_spacing or facet_col_spacing was falsy, so an explicit 0 was ignored. It now uses the default only when the argument is None. This also fixes px.imshow, which goes through the same code.

Testing strategy

Added test_facets_zero_spacing (rows and columns, with and without facet_col_wrap, plus a px.pie case) and test_imshow_facet_spacing_zero. They fail on main and pass with this change.

Additional information (optional)

Disclosure: this change was prepared with help from an AI assistant (Claude). I've reviewed and tested it, and I'll handle the discussion here 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).

init_figure picked the subplot spacing with
`args.get("facet_row_spacing") or 0.07` (and similar for the other
defaults), so an explicit spacing of 0 was treated as unset and the
default gap was used instead. The docstrings allow any float in [0, 1]
and make_subplots accepts 0, so fall back to the default only when the
argument is None. px.imshow builds its facets through the same code
and is fixed too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

px: facet_row_spacing=0 / facet_col_spacing=0 are ignored

1 participant