-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Tidying up and tweaking mplot3d examples [MEP12] #6690
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tidying up and tweaking mplot3d examples [MEP12] #6690
Conversation
for angle in range(0, 360): | ||
ax.view_init(30, angle) | ||
plt.draw() | ||
plt.pause(.001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my computer, this line was needed to make the example viewable. I got the idea for it when I did the wire3d_animation_demo example, but I'm not sure this is the correct practice since in both examples this line seems to trigger a deprecation warning:
/Users/trish/anaconda/lib/python2.7/site-packages/matplotlib-2.0.0b1+1720.ga8ad349.dirty-py2.7-macosx-10.5-x86_64.egg/matplotlib/backend_bases.py:2444: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
warnings.warn(str, mplDeprecation)
Let me know if there's something else I should do with this instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which backend are you using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dumb question: how do I tell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import matplotlib; print(matplotlib.get_backend())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Qt4Agg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm going to make an issue for this, which part is the issue? That nothing displays for me without the use of plt.pause(), or that the use of plt.pause() triggers that warning? I'm not really clear on whether plt.draw() is supposed to be sufficient in an example like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be because plt.draw
is now lazy and won't draw until idle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QuLogic You are correct. plt.pause()
spins the GUI event loop so the update gets processed.
I don't think we need to worry about the warning in this PR, it is a know issue.
|
||
# Set the z axis limits so they aren't recalculated each frame. | ||
ax.set_zlim(-1, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The z axis scale was changing as the rotation progressed, so this seemed like a nice addition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That shouldn't happen. Makes me wonder if it is a bug with the style changes for 2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing a git bisect to try and nail down when this happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this example as a test script, I see the same behaviour with versions 1.5.2, 1.5.1, 1.5.0, 1.4.0, 1.2.0, and 1.0.0. I haven't found a commit where this behaviour doesn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, how about this issue and the other one with regards to "plt.pause()"
get filed as issues? Let's take out those two changes for now and keep it
focused on just MEP12. We'll have to investigate those two issues further
to see if there is something deeper going on.
On Tue, Jul 5, 2016 at 11:14 AM, Trish Gillett-Kawamoto <
notifications@github.com> wrote:
In examples/mplot3d/wire3d_animation_demo.py
#6690 (comment):+# Set the z axis limits so they aren't recalculated each frame.
+ax.set_zlim(-1, 1)Using this example as a test script, I see the same behaviour with
versions 1.5.2, 1.5.1, 1.5.0, 1.4.0, 1.2.0, and 1.0.0. I haven't found a
commit where this behaviour doesn't happen.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/matplotlib/matplotlib/pull/6690/files/6a5def2d4d237346f47e4e9da592f05058b1a9f9#r69580992,
or mute the thread
https://github.com/notifications/unsubscribe/AARy-L05A6cqDxNM8ebAlLR7HrjuixW9ks5qSnTcgaJpZM4JE0ZQ
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just realizing I was thinking of the rotate_axes3d example when I wrote the note saying the z limits changed 'as the rotation progressed'. Sorry for that confusion. In fact it's the data that's changing in this example, not the rotation. As the largest z value contracts from say 1 to 0.6, the z limits are self-adjusting so that the extremes of the surface are always using the full z range. In that updated context, would you say that the behaviour is as expected or does something still sound fishy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TrishGillett That behavior is expected given how this code works.
6a5def2
to
bced32d
Compare
Restarted the failing tests (which are almost certainly un-related). |
I have also restarted the failing test as it seemed unrelated. Thanks for the patch @TrishGillett ! The examples are much better. """
title
description
""" It'll make our life easier when we move to sphinx-gallery, as this is the required format for examples docstring and sphinx-gallery. |
Thanks for the approvals! Duly noted about the docstring structure, I'll check it too from now on. :) |
The travis failure is unrelated, but I have no clue what's going on: it seems a font file is missing. |
Any chance a rebase might help? |
A rebase might help. Not sure what is going wrong with that 2.7 test.... |
I'll do a rebase tonight or tomorrow. While I'm at it, I can change the docstrings like @NelleV mentioned. Is the idea that the 'title' should match the filename (ex. 2dcollections3d_demo.py => '2D Collections 3D Demo')? If not, can you give me an example of what you're going for? |
First, don't feel obliged to do this. Your work on this PR is already a huge improvements of our examples. In short, a blocker for one of my pull request is the migration of our gallery to sphinx-gallery. Unfortunately, sphinx gallery requires that docstring be of the format "title + description". The title is used both in the gallery as a title to each vignette, and as the title of the docstring rendered for each example. I'll go other some of the plots to make suggestions. |
@@ -1,23 +1,38 @@ | |||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A title on that PR could be "3D surfaces"
It's no problem to add the titles, my goal when I do MEP12 PRs is to try and make the examples 'compliant' with all the standards we're shooting for, so I'd rather do it as part of that process than leave it for someone else to come back and do later. Maybe you should modify the 'Add introductory sentence or paragraph in the main docstring' point in the guidelines here to reflect what you need so some MEP12ers can help you chip away at the problem. :) |
That's on my todo list :) |
…catter3d_demo, subplot3d_demo, and text3d_demo: Comments, docstrings and tweaks. [MEP12]
…aks, and refactoring. [MEP12]
…, and refactoring. [MEP12]
…nd refactoring. Notably, viewing angles on tricontour examples are tweaked and the graphs of trisurf3d_demo2 are made into subplots. [MEP12]
bced32d
to
f14e90d
Compare
f14e90d
to
d47dcce
Compare
Added example titles and rebased on master. Travis is running clean now but Appveyor has some complaints. Can someone in the know check if they're related or not? |
Appveyor failures were unrelated. |
Tidying up and tweaking mplot3d examples [MEP12] Conflicts: examples/mplot3d/2dcollections3d_demo.py Conflict resolved by taking the version from #6690
backported to v2.x as a869cc0 |
Thank you, @TrishGillett. |
This PR is the follow up to #6303 and covers clean up work for all the mplot3d examples not covered in that one. It also includes touch ups to an example cleaned up previously, 2dcollections3d_demo. A lot of my changes are docstring and comment additions, but I've also done some rearranging and refactoring in hopes of improving clarity. I'll make line comments on some of the points of interest.