Skip to content

Conversation

@jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented Jan 26, 2026

Added subplot_titles argument to make_subplots that can either pass in a list of new subplot titles or be set to True to maintain existing subplot titles.
Added title argument to make_subplots as well, similar to other charts.

BREAKING CHANGE: Titles passed in from subplots automatically become subplot titles instead of one of them becoming title. Set subplot_titles to False for previous behavior.

Copilot AI and others added 12 commits November 7, 2025 20:53
- Rename use_existing_titles to titles_as_subtitles for clarity
- Remove default value annotations from docstrings
- Extract title handling logic into get_subplot_titles helper function
- Move annotation and title application from unsafe_update_figure to atomic_layer
- Add subplot_annotations and overall_title parameters to atomic_layer and layer
- Update documentation to use simpler language (left to right, top to bottom instead of row-major)
- Update all tests to use titles_as_subtitles
- Simplify extract_title_from_figure to always return string

Co-authored-by: jnumainville <[email protected]>
- Rename 'overall_title' parameter to 'title' in layer function
- Remove unnecessary padding logic from get_subplot_titles (annotations are skipped for missing titles anyway)
- Remove erroneous duplicate return statement in atomic_make_subplots

Co-authored-by: jnumainville <[email protected]>
@jnumainville
Copy link
Collaborator Author

Looks like this needs deephaven/deephaven-core#7596 to pass fully

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

ui docs preview (Available for 14 days)

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

ui docs preview (Available for 14 days)

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

plotly-express docs preview (Available for 14 days)

@jnumainville jnumainville requested review from a team, Copilot and mattrunyon and removed request for a team February 3, 2026 20:50
@jnumainville jnumainville marked this pull request as ready for review February 3, 2026 20:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for subplot titles and an overall title to the make_subplots function in the Deephaven plotly-express plugin. The implementation allows users to specify individual subplot titles via a list or automatically extract titles from existing figures by setting subplot_titles=True. Additionally, users can now add an overall title to the entire subplot figure.

Changes:

  • Added subplot_titles and title parameters to make_subplots function
  • Implemented helper functions for title extraction, annotation creation, and grid position mapping
  • Updated documentation with examples of the new functionality
  • Added comprehensive unit tests for the new features
  • Updated test fixtures for precision handling in datetime comparisons

Reviewed changes

Copilot reviewed 22 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugins/plotly-express/src/deephaven/plot/express/plots/subplots.py Core implementation of subplot titles and overall title functionality
plugins/plotly-express/src/deephaven/plot/express/plots/_layer.py Added support for subplot annotations and title handling in layer function
plugins/plotly-express/test/deephaven/plot/express/plots/test_make_subplots.py Added comprehensive test coverage for new subplot title features
plugins/plotly-express/docs/sub-plots.md Updated documentation with examples of subplot titles and overall title usage
plugins/plotly-express/test/deephaven/plot/express/preprocess/*.py Updated test assertions to use pandas.testing.assert_frame_equal for better precision handling
plugins/plotly-express/test/deephaven/plot/express/plots/test_timeline.py Updated timeline test to handle datetime precision differences
tests/express.spec.ts Added integration tests for titles and subplots
tests/app.d/express.py Added test fixtures using the new functionality
sphinx_ext/sphinx-requirements.txt Added Sphinx version constraint to prevent incompatibility
plugins/plotly-express/setup.cfg Bumped deephaven-core dependency to 0.41.1
plugins/plotly-express/docs/snapshots/*.json Updated documentation snapshots
tests/express.spec.ts-snapshots/*.png Added visual regression test snapshots

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jnumainville jnumainville requested a review from Copilot February 3, 2026 21:55
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

plotly-express docs preview (Available for 14 days)

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

ui docs preview (Available for 14 days)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 28 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

ui docs preview (Available for 14 days)

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

plotly-express docs preview (Available for 14 days)

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

ui docs preview (Available for 14 days)

packages=find_namespace:
install_requires =
deephaven-core>=0.37.6
deephaven-core>=0.41.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a version? We have 0.40.x and 41.x

Comment on lines +467 to +469
title:
Title to set for the figure. If False, removes any autogenerated title.
If None, leaves the title as is.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the autogenerated title apply to subplots? Like what gets generated?

What is the case where you would want to remove auto generated? Could you just set it to empty string instead of False or would that cause some layout issues?

Comment on lines +284 to +287
col_starts: List of column start positions
col_ends: List of column end positions
row_starts: List of row start positions
row_ends: List of row end positions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add that all of these are in "user's natural index" (top-left is 0)

Does the subplot API take screen coordinates, but plotly uses grid coordinates internally?

rows: int,
cols: int,
) -> list[dict]:
"""Create annotations for subplot titles
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this how Plotly does it (as an annotation) or are we doing something different and it must be an annotation?

https://plotly.com/python/subplots/ the "Multiple Subplots with Titles" here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They also do it with annotations, around here

"""Get the list of subplot titles based on parameters

Args:
grid: The grid of figures (already reversed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would clarify what reversed is here (bottom-left is 0,0?)

col_starts, col_ends = get_domains(column_widths, horizontal_spacing)
row_starts, row_ends = get_domains(row_heights, vertical_spacing)
# In the case of rows, the last figure is the one at the top, so add an end_margin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always true? Does the order of creating subplots matter?

# This
fig.add_trace(row=1, col=1)
fig.add_trace(row=2, col=1)

# Vs this
fig.add_trace(row=2, col=1)
fig.add_trace(row=1, col=1)

Comment on lines +578 to +582
subplot_titles:
True by default, which automatically extracts and uses titles from the input figures
as subplot titles.
If False, one of the subplot titles ends up as the chart title.
See the title parameter to override this behavior.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we prefer an empty list/None instead of boolean + list as the type? Not sure if that would complicate things or if that deviates from plotly

Comment on lines +674 to +683
def test_make_subplot_titles_with_grid(self):
import src.deephaven.plot.express as dx

chart1 = dx.scatter(self.source, x="X", y="Y", title="Chart A")
chart2 = dx.scatter(self.source, x="X", y="Y", title="Chart B")
chart3 = dx.scatter(self.source, x="X", y="Y", title="Chart C")
chart4 = dx.scatter(self.source, x="X", y="Y", title="Chart D")

grid = [[chart1, chart2], [chart3, chart4]]
charts = dx.make_subplots(grid=grid).to_dict(self.exporter)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens (or should happen) if there is a title on the chart and also subplot_titles passed to make_subplots? Should add a test for that case

@@ -1,6 +1,7 @@
import unittest

from ..BaseTest import BaseTestCase
import pandas.testing as tm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why these pandas test changes are in this PR

dx.scatter(express_source, x="Values", y="Values2", title="Subplot 1"),
dx.scatter(express_source, x="Values", y="Values2", title="Subplot 2"),
cols=2,
subplot_titles=True,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this explicit true needed? Should we omit it to test default behavior instead?

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.

4 participants