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

Fix mplot3d projection#8896

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

eric-wieser
Copy link
Contributor

@eric-wiesereric-wieser commentedJul 16, 2017
edited
Loading

Fixes#8894 andfixes#1104, replacing the bad rendering in the first image, with the good rendering in the second:

image

image

Unsurprisingly, this breaks every single unit test,

The plots now all look rather cubic - but that's better than distorted, and we could go back to correctly-scaled rectangles with#8593

darkdragon-001 reacted with thumbs up emoji
@@ -985,6 +999,8 @@ def get_proj(self):
point.

"""
pb_aspect = np.array([1, 1, 0.75])
Copy link
ContributorAuthor

@eric-wiesereric-wieserJul 16, 2017
edited
Loading

Choose a reason for hiding this comment

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

Strictly speaking, this isn't just the aspect, but also the scaling. Is there already scaling in place somewhere else? Seems too convenient that everything just magically fits into the viewing area.

@eric-wiesereric-wieserforce-pushed thefix-mplot3d-projection branch 2 times, most recently from9355ac4 to5922eddCompareJuly 16, 2017 22:28
@eric-wieser
Copy link
ContributorAuthor

Plot is now scaled to sort-of look like it did before, in the default view.

Note that because the plot is now actually stretched horizontally, but the camera is not, the view angle looks different. Options:

  • Change the default view angle too - presumably overriden in matplotlibrc though?
  • Change the defaultpb_aspect back to a cube
  • Deal with it

@eric-wieser
Copy link
ContributorAuthor

Reasonably straightforward to implement axis=equal from here too

@tacaswelltacaswell added this to the2.2 (next next feature release) milestoneJul 18, 2017
# in the superclass, we would go through and actually deal with axis
# scales and box/datalim. Those are all irrelevant - all we need to do
# is make sure our coordinate system is square.
figW, figH = self.get_figure().get_size_inches()
Copy link
Member

Choose a reason for hiding this comment

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

Why use the figure's aspect ratio? What if the figure has 3 subplots all in a row?

Copy link
ContributorAuthor

@eric-wiesereric-wieserAug 2, 2017
edited
Loading

Choose a reason for hiding this comment

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

Because all sizes in matplotlib are relative to the figure.pb.shrunk_to_aspect seems to take the ratio of the top-level parent (the figure), and the desired ratio. This is because the end result is the size relative to the parent, as all objects in matplotlib seem to be sized - so to ensure a given aspect ratio, you need to account for that of the parent

Note that this is the same as the normal aspect=equal code, so is presumably correct.

Copy link
Member

Choose a reason for hiding this comment

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

Ping@efiring, as I think you are the resident expert on all the ways this could possibly go wrong.

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense. I have no intention of spending the time required to understand mplot3d well enough to make a detailed review, but in the absence of any such review I am inclined to trust that this PR is a major improvement, as it appears to be fixing a basic design flaw.

@WeatherGod
Copy link
Member

WeatherGod commentedAug 2, 2017 via email

I wouldn't really know. I think@efiring is the expert on these things.
On Wed, Aug 2, 2017 at 4:53 PM, Eric Wieser ***@***.***> wrote: ***@***.**** commented on this pull request. ------------------------------ In lib/mpl_toolkits/mplot3d/axes3d.py <#8896 (comment)> : > @@ -247,6 +247,20 @@ def tunit_edges(self, vals=None, M=None): (tc[7], tc[4])] return edges + def apply_aspect(self, position=None): + if position is None: + position = self.get_position(original=True) + + # in the superclass, we would go through and actually deal with axis + # scales and box/datalim. Those are all irrelevant - all we need to do + # is make sure our coordinate system is square. + figW, figH = self.get_figure().get_size_inches() Because all sizes in matplotlib are relative to the figure. pb.shrunk_to_aspect seems to take the ratio of the top-level parent (the figure), and the desired ratio. Note that this is the same as the normal aspect=equal code, so is presumably correct. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#8896 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AARy-E32123ChZda_Y-gPCtOSEXUWFvjks5sUOHjgaJpZM4OZVo9> .

return 'azimuth=%d deg, elevation=%d deg ' % (self.azim, self.elev)
# ignore xd and yd and display angles instead
return 'azimuth={:.0f} deg, elevation={:.0f} deg '.format(
self.azim, self.elev)
Copy link
ContributorAuthor

@eric-wiesereric-wieserDec 10, 2017
edited
Loading

Choose a reason for hiding this comment

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

Bug fixed here on fractional view angles

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Extracted to#12573. I misremembered - the crash was only for non-finite values.

@darkdragon-001
Copy link

Any progress here?

@timhoffm
Copy link
Member

Unfortunately not. Progress would be noted here.

@eric-wieser
Copy link
ContributorAuthor

I was under the impression the ball was not in my court here. Rebasing shouldn't be too awful, but I don't see much point without further review.

@timhoffm
Copy link
Member

@eric-wieser Not an expert in mpl3d and thus I have no idea who would have to take up the torch. I was just stating that the thread still reflects the current status.

@eric-wieser
Copy link
ContributorAuthor

@timhoffm: I'll rebase for good measure, it'll allow someone to work from this branch at least if they need cubic plots.

Can you remind me how to regenerate the baseline_images? Is there a mechanism to say "assume the new image is correct for all failed image comparison tests"?

Copy link
Member

@efiringefiring left a comment

Choose a reason for hiding this comment

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

In the interest of getting things moving, I will approve of this subject to the necessary rebase and addition of "what's new" and "API changes" entries. I will defer to@WeatherGod, however, if he has concrete objections. Same with respect to@tacaswell who might object because this is making a big behavior change.

# in the superclass, we would go through and actually deal with axis
# scales and box/datalim. Those are all irrelevant - all we need to do
# is make sure our coordinate system is square.
figW, figH = self.get_figure().get_size_inches()
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense. I have no intention of spending the time required to understand mplot3d well enough to make a detailed review, but in the absence of any such review I am inclined to trust that this PR is a major improvement, as it appears to be fixing a basic design flaw.

@timhoffm
Copy link
Member

@eric-wieser
Copy link
ContributorAuthor

Copy the output images (in this case result_images/test_lines/test_line_dashes.png) to the correct subdirectory of baseline_images tree in the source directory

I was hoping there was automation for "assume every failed output is an intended change, overwrite the baseline" so that I can diff with git.

@jklymak
Copy link
Member

I was hoping there was automation for "assume every failed output is an intended change, overwrite the baseline" so that I can diff with git.

Can you just rsyncresult_images/ andlib/matplotlib/tests/baseline_images?

@efiring
Copy link
Member

No, rsync is not the right tool--you need to explicitly copy the appropriate files from result_images, not all of them.

@jklymak
Copy link
Member

Certainly you dont want to git add all the comparison files.

@anntzer
Copy link
Contributor

triage_tests.py has keyboard shortcuts (run with -h to get the help) to accept images and move between them ("A"/"down"/"A"/"down"/etc should get you there).

eric-wieser reacted with thumbs up emoji

@eric-wieser
Copy link
ContributorAuthor

@anntzer: Great tool, thanks. Rebased with updated tests

@eric-wiesereric-wieserforce-pushed thefix-mplot3d-projection branch 2 times, most recently from9f8cc4c toa7a8051CompareMarch 27, 2019 03:49
@eric-wieser
Copy link
ContributorAuthor

I don't understand the circle-ci failures:

/home/circleci/project/lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.apply_aspect:4: WARNING: more than one target found for cross-reference 'get_anchor': matplotlib.axes.Axes.get_anchor, mpl_toolkits.axes_grid1.axes_divider.AxesDivider.get_anchor, mpl_toolkits.axes_grid1.axes_divider.Divider.get_anchor

It seems that travis is failing the svg tests, but the svg files are no longer being generated on my machine.

@eric-wieser
Copy link
ContributorAuthor

Thanks for the fixups@anntzer, they look fine to me

@eric-wieser
Copy link
ContributorAuthor

What is the status of this?

Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

Looking through all of the changed images

  • lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_notshaded.png
  • lib/mpl_toolkits/tests/baseline_images/test_mplot3d/scatter3d_color.png
  • lib/mpl_toolkits/tests/baseline_images/test_mplot3d/scatter3d.png
  • lib/mpl_toolkits/tests/baseline_images/test_mplot3d/surface3d_shaded.png

give me a bit of pause, but I think those are all consequences of the 2.0 default value changes, not due to anything in this PR.

@tacaswell
Copy link
Member

I'm not comfortable merging this over@WeatherGod 's requested changes, however I believe they are addressed.

@eric-wieser
Copy link
ContributorAuthor

but I think those are all consequences of the 2.0 default value changes, not due to anything in this PR.

I've tried to make that easy to look at by having separate commits for the style and other changes - so hopefully you can confirm whether those changes matter.

@WeatherGodWeatherGod merged commit62d8d65 intomatplotlib:masterFeb 7, 2020
Comment on lines +983 to +984
# chosen for similarity with the initial view before gh-8896
pb_aspect = np.array([4, 4, 3]) / 3.5
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I imagine that there are going to be some requests for an API to change this, for people who liked their 1:1:1 plot boxes. I started working on that two years ago, but it opened a can of worms that I didn't want to open concurrently with this PR. At some point I'll see if I can rebase those changes.

@tacaswell
Copy link
Member

Please seehttps://discourse.matplotlib.org/t/removed-commits-from-master-branch/20868 This merge was "un-done" so that we can re-do it and squash.

@WeatherGod
Copy link
Member

Sorry for causing such churn in the repo. I completely forgot to double-check how many image commits there were.

@eric-wieser
Copy link
ContributorAuthor

To be clear, is the current status of this "not actually merged"?

@anntzer
Copy link
Contributor

Yes. I think you can reopen a PR with the same commits, except that the intermediate images should be stripped out (so yes the intermediate commits won't be testable independently).

@eric-wiesereric-wieser mentioned this pull requestFeb 11, 2020
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestMay 27, 2020
To make bbox_inches='tight' work correctly, we cache the positions ofall of the axes, change their aspect to 'auto', adjust the transformson the figure, render the output, and then restore the previoussetting of aspect to each of the figures.  This prevent the Axes fromtrying to adjust their size on draw. This matters because for therender that is emitted the figure transforms are out of sync with thefigure size.As part of cleaning fixing the rendering of Axes3D inmatplotlib#8896 /matplotlib#16472we started to use apply_aspect to re-size the area the Axes3D takes upto maintain a fixed ratio between the axes when the aspect is "auto".However this conflicts with the expectation in tight_bbox.adjust_bboxas it assumes setting the aspect to "auto" will prevent any axesresizing.This commit addresses this by: - exiting the Axes3D.apply_aspect early if aspect is auto - adding a new aspect mode 'auto_pb' which is the default   for Axes3D which maintains the current master branch behavior   of maintaining a fixed ratio between the sizes of the x, y z axis   independent of the data limits. - re implement several functions on Axes3D to make sure they handle   sharez correctly.closesmatplotlib#16463.
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestMay 30, 2020
The way that bbox_inches='tight' is implemented we need to ensure thatwe do not try to adjust the aspect during the draw (because we havetemporarily de-coupled the reported figure size from the transformswhich results in the being distorted).  Previously we did not have away to fix the aspect ratio in screen space of the Axes (only theaspect ratio in dataspace) however in 3.3 we gained this ability forboth Axes (matplotlib#14917) and Axes3D (matplotlib#8896 /matplotlib#16472).Rather than add an aspect value to `set_aspect` to handle this case,in the tight_bbox code we monkey-patch the `apply_aspect` method witha no-op function and then restore it when we are done.  Previously wewould set the aspect to "auto" and restore it in the same places.closesmatplotlib#16463.
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestJun 4, 2020
The way that bbox_inches='tight' is implemented we need to ensure thatwe do not try to adjust the aspect during the draw (because we havetemporarily de-coupled the reported figure size from the transformswhich results in the being distorted).  Previously we did not have away to fix the aspect ratio in screen space of the Axes (only theaspect ratio in dataspace) however in 3.3 we gained this ability forboth Axes (matplotlib#14917) and Axes3D (matplotlib#8896 /matplotlib#16472).Rather than add an aspect value to `set_aspect` to handle this case,in the tight_bbox code we monkey-patch the `apply_aspect` method witha no-op function and then restore it when we are done.  Previously wewould set the aspect to "auto" and restore it in the same places.closesmatplotlib#16463.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer left review comments

@efiringefiringefiring approved these changes

@tacaswelltacaswelltacaswell approved these changes

@WeatherGodWeatherGodWeatherGod approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.3.0
Development

Successfully merging this pull request may close these issues.

mplot3d projection results in non-orthogonal axes Resizing a GUI window with Axes3D
10 participants
@eric-wieser@WeatherGod@darkdragon-001@timhoffm@jklymak@efiring@anntzer@jpaulos@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp