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

Filter out inf values in plot_surface#26253

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
tacaswell merged 4 commits intomatplotlib:mainfromLemonBoy:inf-surf
Aug 3, 2023

Conversation

LemonBoy
Copy link
Contributor

PR summary

Extend the logic introduced by#20725 for NaN values to inf values,
avoiding the introduction of infinite vertices in the mesh that wreak
havoc when performing the z-sorting.

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.

@tacaswell
Copy link
Member

Thank you for your work on this.

If I am understanding the test example correctly, one of the quadrants sets the z value toinf which by some mechanism messes with the z-sorting of between the other quadrents:

importmatplotlib.pyplotaspltimportnumpyasnpfig=plt.figure()ax=fig.add_subplot(projection="3d")x,y=np.mgrid[-2:2:0.1,-2:2:0.1]z=np.sin(x)**2+np.cos(y)**2z[x.shape[0]//2 :,x.shape[1]//2 :]=np.infax.plot_surface(x,y,z,cmap="jet")ax.view_init(elev=45,azim=145)

so

vs what it should look like (a different angle)

so2

I agree something is definitely wrong, but I suspect it may be better to fix this in the code inCollection3D that sorts the patchs rather than by dropping all non-finite data on the floor.

There has been a push recently to make the 2D mesh-like methods do a better job of holding onto the shape of the originally passed in data (to make it easier to update x / y / color / ... after the fact). We have not (to my knowledge) done anything similar with the 3D methods yet, but we may want to go that way eventually. This also suggests that the right place to filter out the non-finite data is in the sorting step, not in the "what data are we holding" step.

@tacaswelltacaswell added this to thev3.9.0 milestoneJul 6, 2023
@LemonBoy
Copy link
ContributorAuthor

I agree something is definitely wrong, but I suspect it may be better to fix this in the code in Collection3D that sorts the patchs rather than by dropping all non-finite data on the floor.

That was my initial guess too, but the linked issue pointed towards this dataset-cleaning approach.

We have not (to my knowledge) done anything similar with the 3D methods yet, but we may want to go that way eventually. This also suggests that the right place to filter out the non-finite data is in the sorting step, not in the "what data are we holding" step.

What I am afraid of is the additional complexity of having to filter the dataset whenever it's needed, eg. before the z-sort, before computing the colormap min/max values, etc. However, if the general consensus is to remove the preliminary data filtering I'd be happy to send another patch soon.

@LemonBoy
Copy link
ContributorAuthor

Friendly ping.

@timhoffm
Copy link
Member

Fundamentally, I agree with@tacaswell that the Collection should hold all data, and handling of nan and inf should be done in there.

Given that the nan handling was already implemented on the outer level in#20725, it is bearable to extend that logic to include inf values as well. It's an improvement in the sense, that we fix a buggy plot. We'll anyway have to do an API change for the existing code when we want to move nonfinite data handling into the 3D Collections.

Extend the logic introduced bymatplotlib#20725 for NaN values to inf values,avoiding the introduction of infinite vertices in the mesh that wreakhavoc when performing the z-sorting.Sadly I don't have a minimal test case for this problem.
Oops, my bad.
Copy link
Contributor

@scottshambaughscottshambaugh left a comment

Choose a reason for hiding this comment

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

Agree with the above that we should think about how to better / more generically handle this issue, but we shouldn't let perfect be the enemy of the good. This fixes a bug in a straightforward way, gets my thumbs up.

@timhoffm
Copy link
Member

Can this still go to 3.8?

@tacaswelltacaswell modified the milestones:v3.9.0,v3.8.0Aug 3, 2023
@tacaswelltacaswell merged commit83b3fef intomatplotlib:mainAug 3, 2023
@oscargusoscargus mentioned this pull requestSep 17, 2023
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

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

@timhoffmtimhoffmtimhoffm approved these changes

@scottshambaughscottshambaughscottshambaugh approved these changes

Assignees
No one assigned
Projects
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

4 participants
@LemonBoy@tacaswell@timhoffm@scottshambaugh

[8]ページ先頭

©2009-2025 Movatter.jp