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

Added test_hist2d#27418

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
rupink wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromrupink:test_hist2d
Open

Added test_hist2d#27418

rupink wants to merge2 commits intomatplotlib:mainfromrupink:test_hist2d

Conversation

rupink
Copy link

PR summary

I have added a test for Axes.hist2d in lib/matplotlib/tests/test_datetime.py that tests with randomly created data if the data correctly plots. It is similar to the Axes.hist method of testing, as it uses similar generated data and methods.

This addresses the Axes.hist2d task from#26864.

Below is a picture of the generated plots.
image

PR checklist

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

Comment on lines +365 to +367
values1 = np.random.randint(1, 10, 30)
values2 = np.random.randint(1, 10, 30)
values3 = np.random.randint(1, 10, 30)
Copy link
Member

Choose a reason for hiding this comment

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

If you want to use randomness, you'll need to set a seed (we use 19680801 for tests).

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense

Comment on lines +375 to +380
hist2d1 = ax1.hist2d(
x_values,
values1,
bins=10,
cmap='Blues'
)
Copy link
Member

Choose a reason for hiding this comment

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

This fits in one line, AFAICT.

rupink reacted with thumbs up emoji
Comment on lines +383 to +397
hist2d2 = ax2.hist2d(
x_values,
values2,
bins=10,
cmap='Greens'
)
ax2.set_title('Axes.hist2d - Data 2')

hist2d3 = ax3.hist2d(
x_values,
values3,
bins=10,
cmap='Reds'
)
ax3.set_title('Axes.hist2d - Data 3')
Copy link
Member

Choose a reason for hiding this comment

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

I don't see what the difference is between the first plot and these two?

Copy link
Member

Choose a reason for hiding this comment

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

To possibly clarify a bit: it would make more sense to use dates for the y-values as well. So one idea is to keep one of the subplots, swap x and y values for the next (dates on y-axis) and let the third have dates for both x and y-values.

ksunden and rupink reacted with thumbs up emoji
@QuLogicQuLogic mentioned this pull requestDec 2, 2023
64 tasks
Co-authored-by: Kyle Sunden <git@ksunden.space>
values2 = np.random.randint(1, 10, 30)
values3 = np.random.randint(1, 10, 30)

x_values = mpl.dates.date2num([start_date + i * time_delta for i in range(30)])
Copy link
Member

Choose a reason for hiding this comment

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

date2num means you are passing numbers intohist2d. We want to test actual dates.


# Using Axes.hist2d
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, constrained_layout=True)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fig, (ax1,ax2,ax3)=plt.subplots(1,3,constrained_layout=True)
fig, (ax1,ax2,ax3)=plt.subplots(1,3,layout='constrained')

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@ksundenksundenksunden left review comments

@oscargusoscargusoscargus left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
Status: No status
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@rupink@QuLogic@ksunden@oscargus@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp