Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Add datetime support to _mean()#5368
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
m-ad wants to merge4 commits intoplotly:mainChoose a base branch fromm-ad:fix_add_vline_with_annotation_to_datetime_axis
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+71 −1
Open
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
f5a53af Allow for vlines on datetime axes with annotations by extending _mean…
m-ad8a46c4c remove type hints for python 3.8 compatibility
m-adff88033 revert an accidental change not related to this feature to keep the P…
m-ad7944e0f Merge branch 'main' into fix_add_vline_with_annotation_to_datetime_axis
emilyklFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
24 changes: 23 additions & 1 deletionplotly/shapeannotation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletionstests/test_optional/test_autoshapes/test_date_axis_annotated_shapes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """Tests for annotated axis-spanning shapes with datetime coordinates. | ||
| These tests cover the regression described in GitHub issue #3065: | ||
| https://github.com/plotly/plotly.py/issues/3065 | ||
| """ | ||
| from datetime import datetime | ||
| import plotly.express as px | ||
| import plotly.graph_objects as go | ||
| def test_add_vline_with_date_annotation_express(): | ||
| """MWE from Github issue https://github.com/plotly/plotly.py/issues/3065""" | ||
| df = px.data.stocks(indexed=True) | ||
| fig = px.line(df) | ||
| fig.add_vline(x="2018-09-24", annotation_text="test") | ||
| def test_add_vline_with_date_annotation(): | ||
| fig = go.Figure() | ||
| # Provide a couple of traces so axis type is inferred as date from data | ||
| dates = [datetime(2025, 9, 23), datetime(2025, 9, 24), datetime(2025, 9, 25)] | ||
| fig.add_scatter(x=dates, y=[1, 2, 3]) | ||
| fig.add_vline(x=dates[1], annotation_text="Test") | ||
| # Ensure one annotation was added and x coordinate preserved | ||
| annotations = getattr(fig.layout, "annotations", []) | ||
| assert len(annotations) == 1 | ||
| ann = annotations[0] | ||
| assert ann.x == dates[1] | ||
| assert ann.text == "Test" | ||
| def test_add_hline_with_date_annotation(): | ||
| fig = go.Figure() | ||
| # Provide a couple of traces so axis type is inferred as date from data | ||
| dates = [datetime(2025, 9, 23), datetime(2025, 9, 24), datetime(2025, 9, 25)] | ||
| fig.add_scatter(y=dates, x=[1, 2, 3]) | ||
| fig.add_hline(y=dates[1], annotation_text="Test") | ||
| # Ensure one annotation was added and x coordinate preserved | ||
| annotations = getattr(fig.layout, "annotations", []) | ||
| assert len(annotations) == 1 | ||
| ann = annotations[0] | ||
| assert ann.y == dates[1] | ||
| assert ann.text == "Test" |
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.