FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BUG: Fix face orientations of bar3d by eric-wieser · Pull Request #12259 · matplotlib/matplotlib · GitHub

Repository navigation

BUG: Fix face orientations of bar3d - #12259

Merged
timhoffm merged 2 commits into
matplotlib:masterfrom
eric-wieser:bar3d-counterclockwise-faces
Nov 11, 2018
Merged

timhoffm merged 2 commits into
matplotlib:masterfrom
eric-wieser:bar3d-counterclockwise-faces

Conversation

eric-wieser commented Sep 25, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes #12138, which is caused by these incorrect orientations

I was hoping I could modify the existing bar3d test with something like:

@pytest.mark.parametrize('azim', [-60, 60])
@image_comparison(
    baseline_images=['bar3d_shaded'],
    remove_text=True,
    extensions=['png']
)
def test_bar3d_shaded(azim):
    ...
    ax.view_init(azim=azim)

but I couldn't work out how to make parametrize work with the baseline_images argument of image_comparison

eric-wieser commented Sep 25, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Worked out how to parametrize the test.

Let me know if you'd like to see the test in a separate PR, to make the result easier to compare.

Edit: Done in #12273 - will rebase this after that.

dstansby added topic: mplot3d MEP: MEP13 artist properties and removed MEP: MEP13 artist properties labels Sep 25, 2018
dstansby added this to the v3.1 milestone Sep 25, 2018
eric-wieser force-pushed the bar3d-counterclockwise-faces branch from c894a71 to d6d43e9 Compare September 25, 2018 16:33

Copy link
Copy Markdown
Member

Would it be possible to stick the test images on different axes on the same figure (something like subplots(2, 2)? This will save a few images, and also make a nice side by side comparison of the different viewing angles.

Copy link
Copy Markdown
Contributor Author

I avoided that because it leads to a 100% diff in the target image, and also removes the ability to use pytest.parametrize.

However, I'm not super committed to that decision - if you think that'd be best, can you comment to that effect on #12273?

Copy link
Copy Markdown
Contributor Author

@dstansby: How does #12292 look?

eric-wieser force-pushed the bar3d-counterclockwise-faces branch from d6d43e9 to b527911 Compare September 26, 2018 16:43

eric-wieser commented Sep 26, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Updated. Something odd seems to be happening though - the light source is above the plot, yet it renders as if it were below. - resolved - _generate_normals was wrong

Might also be worth considering changing the default lighting angle so that it doesn't hit cuboids at exactly 45 degrees causing adjacent faces to be the same color.

eric-wieser force-pushed the bar3d-counterclockwise-faces branch from b527911 to e9b652e Compare September 26, 2018 17:07

Copy link
Copy Markdown
Member

I would have thought that the reason for the two bright faces is that, independent of the viewing angle, you have one bright face facing the viewer. Is this undesireable?
I think it would be good to see the same case visually with a before/after - comparisson here.

eric-wieser commented Oct 4, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

@ImportanceOfBeingErnest: you have that before/after comparision in the rich diff of the result image

An argument for why this should be fixed - for graphs containing both a surface and a bar plot, this will make the shading consistent.

Copy link
Copy Markdown
Member

So for surface plots the lightsource rotates together with the coordinate frame as well. I never noticed that, but now that you mention it, it's clear. (Somehow undesired in my eyes, I would much rather have the lightsource constant in the room and rotate the plot alone, instead of rotating the whole room with its lights, but that's not for debate here I guess.)

Would there be any way to make it consistent for the zero-extent bar as well?

eric-wieser commented Oct 20, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Ugh, I didn't see you'd replied here.

Somehow undesired in my eyes, I would much rather have ...

I agree, that would be a neat feature. I'm working on adding shading to some extra plots- once that's done, maybe I'll investigate a fixed light source.

Would there be any way to make it consistent for the zero-extent bar as well?

That's a bug I'd rather not deal with yet that comes down to z-sorting coincident faces. We only got away with it before because the upper and lower faces were the same color. I'd prefer to leave that to a later PR, where the approach would be either:

  • Sort by normal vector in the case of coincident faces
  • Cull all faces with a back-pointing normal vector
    At least right now it looks correct from the top, which is probably the more important side.

Before I can reasonably do that, I'd like to get this and then #12136 in.

Comment thread lib/mpl_toolkits/mplot3d/axes3d.py Outdated

anntzer commented Oct 31, 2018

Copy link
Copy Markdown
Contributor

Why did the notshaded baseline image change?

eric-wieser commented Oct 31, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Why did the notshaded baseline image change?

Because some faces are now rendered with the points in reverse order, and I guess the renderer somehow cares about that. The diff can be seen here:

There's a handful of changed pixels (shown in red) along the bottom axis, and the other edges.

eric-wieser force-pushed the bar3d-counterclockwise-faces branch from e9b652e to 7bcc001 Compare October 31, 2018 15:57

Copy link
Copy Markdown
Contributor Author

Not sure why CI fails

Copy link
Copy Markdown
Contributor Author

Looks like it maybe just needs rebasing on top of a commit with CI configured. Shall I go ahead and do that?

This makes the next commit easier to follow
Fixes matplotlib#12138, which is caused by these incorrect orientations.

This also corrects _generate_normals to use a counterclockwise convention
eric-wieser force-pushed the bar3d-counterclockwise-faces branch from 7bcc001 to 67fc7c1 Compare November 10, 2018 21:35

Copy link
Copy Markdown
Contributor Author

@dstansby: Rebased

eric-wieser force-pushed the bar3d-counterclockwise-faces branch from 67fc7c1 to 05c60cc Compare November 10, 2018 22:14
timhoffm merged commit 3e90025 into matplotlib:master Nov 11, 2018

Copy link
Copy Markdown
Contributor Author

Was hoping you'd merge rather than squash to keep me from having to rebase. Oh well - thanks for putting this in anyway!

QuLogic commented Nov 11, 2018

Copy link
Copy Markdown
Member

That setting is sticky, so I don't know if @timhoffm did that on purpose (I wouldn't have squashed for this PR). If it wasn't on purpose, please @timhoffm be careful on the next merge.

Copy link
Copy Markdown
Contributor Author

The stickiness has caught me out in the past too.

Copy link
Copy Markdown
Member

On the weekly call on 29 oct it was discussed that all PRs should be squashed-merged if possible to keep the history cleaner and reduce security risks. I think if someone does not want this to happen for their PR they should mention it.

QuLogic commented Nov 14, 2018

Copy link
Copy Markdown
Member

Hmm, that probably should be announced. I'm also not particularly for it when it's an experienced contributor.

Copy link
Copy Markdown
Member

Sorry if squashing caused troubles. The changes seemed rather small and related so that I did not consider it important to keep separate commits.

+1 that an author should explicitly mention that commits should not be squashed.

eric-wieser deleted the bar3d-counterclockwise-faces branch March 23, 2019 18:06
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL