-
Notifications
You must be signed in to change notification settings - Fork 17
feat: DH-20808: Add subplot_titles and title parameters to make_subplots #1283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…_subplots Co-authored-by: jnumainville <[email protected]>
Co-authored-by: jnumainville <[email protected]>
Co-authored-by: jnumainville <[email protected]>
Co-authored-by: jnumainville <[email protected]>
…ncation logic Co-authored-by: jnumainville <[email protected]>
…title check Co-authored-by: jnumainville <[email protected]>
Co-authored-by: jnumainville <[email protected]>
- 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]>
|
Looks like this needs deephaven/deephaven-core#7596 to pass fully |
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
|
plotly-express docs preview (Available for 14 days) |
There was a problem hiding this 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_titlesandtitleparameters tomake_subplotsfunction - 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.
plugins/plotly-express/src/deephaven/plot/express/plots/subplots.py
Outdated
Show resolved
Hide resolved
|
plotly-express docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
There was a problem hiding this 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.
plugins/plotly-express/src/deephaven/plot/express/plots/subplots.py
Outdated
Show resolved
Hide resolved
|
ui docs preview (Available for 14 days) |
|
plotly-express docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
| packages=find_namespace: | ||
| install_requires = | ||
| deephaven-core>=0.37.6 | ||
| deephaven-core>=0.41.1 |
There was a problem hiding this comment.
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
| title: | ||
| Title to set for the figure. If False, removes any autogenerated title. | ||
| If None, leaves the title as is. |
There was a problem hiding this comment.
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?
| 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)| 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. |
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
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. Setsubplot_titlestoFalsefor previous behavior.