Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add test_bar in test_datetime#27033

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

Merged

Conversation

kots14
Copy link
Contributor

@kots14kots14 commentedOct 8, 2023
edited
Loading

PR summary

Version 4:
Modified tests and raised a revision

Version 4 Image output -
TestBar

Version 3:
Modified tests and raised a revision

Version 3 Image output -
TestBar

Version 2:
Modified tests as perthis andthis

Version 2 Image output -
RevisionBarGraphMatplotlib

Version 1:
Adding code fortest_bar method intest_datetime.py mentioned in#26864

Version 1 Image output -
matplotlib_bar

PR checklist

Copy link
Member

@ksundenksunden left a comment

Choose a reason for hiding this comment

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

I think the bar graphs with dates on the vertical (forbar, horizonatal forbarh) axis should be given a bit more care here. That there is an implicit0 mark, which results in1970-01-01 is not a particularly good representation of a bar plot.

I think that for this, there should be abottom argument specified as a datetime and then using atimedelta instead of adatetime for the heights, as indicated by thebardocstring

Here is some code I wrote for someone who had started working on this but never opened a PR:

importmatplotlib.pyplotaspltimportnumpyasnpfromdatetimeimportdatetime,timedeltaimportmatplotlibasmplmpl.rcParams["date.converter"]='concise'fig, (ax1,ax2)=plt.subplots(2,1,layout='constrained')price_date=np.array([datetime(2020,6,30),datetime(2020,7,22),datetime(2020,8,3),datetime(2020,9,14)],dtype=np.datetime64)price_close= [8800,2600,8500,7400]start_date=np.datetime64(datetime(2020,6,1))ax1.bar(price_date,price_close,width=np.timedelta64(4,"D"))ax2.bar(np.arange(4),price_date-start_date,bottom=start_date)

Note thestart_date andprice_date-start_date in this example.

kots14 reacted with thumbs up emoji
@ksunden
Copy link
Member

Also, while in your example it is not a bad width, I may suggest also testing thewidth argument (in units oftimedelta) when the horizontal axis is datetime'd, as that is another place where problems could creep in in this method in particular.

@kots14
Copy link
ContributorAuthor

Thanks for the suggestions. I'll modify the code and raise a revision.

@kots14
Copy link
ContributorAuthor

I'll be raising the revision in next 3 days.

@kots14
Copy link
ContributorAuthor

@ksunden I've raised a revision. Please review the changes.

@kots14kots14 requested a review fromksundenOctober 15, 2023 17:28
@ksunden
Copy link
Member

There still appear to be the implicit 1970 in the new version

And it is very hard to see what is happening in especially the middle two plots (but also the top plot) as the widths overlap all of the bars. A single width is probably sufficient, we just mostly want to test it out that it handles the units as expected, so changing from the default is a good check.

@kots14
Copy link
ContributorAuthor

kots14 commentedOct 16, 2023
edited
Loading

Noted.
I'll modify the PR.
Update : Need 2 more days before raising the revision.

@kots14
Copy link
ContributorAuthor

@ksunden
I've raised a revision. Please review.

@kots14kots14 requested a review fromksundenOctober 24, 2023 19:25
Copy link
Member

@ksundenksunden left a comment

Choose a reason for hiding this comment

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

bar

I was confused by the image added in the post,which seemed to get rid of the date axis on the y axis of the bottom plot, but I actually do keep it when I run this code, see attached.

kots14 reacted with thumbs up emoji
@ksundenksunden added this to thev3.9.0 milestoneOct 26, 2023
@QuLogicQuLogic merged commit4b77763 intomatplotlib:mainDec 5, 2023
@kots14kots14 deleted the axes-bar-unit-test-for-issue-26864 branchJanuary 1, 2024 10:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic approved these changes

@ksundenksundenksunden approved these changes

Assignees
No one assigned
Projects
Milestone
v3.9.0
Development

Successfully merging this pull request may close these issues.

4 participants
@kots14@ksunden@QuLogic@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp