Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Axes get_children order to match draw order #4014

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

Merged
merged 6 commits into from
May 15, 2015

Conversation

blink1073
Copy link
Member

get_children is used by hitlist, and should match the ordering used by draw. Also consolidates so the order is only established in one place, and draw calls get_children to get the proper ordering.

@blink1073
Copy link
Member Author

I would recommend calling get_children in draw, and then removing artists if they are not going to be rendered, so they stay in sync.

@blink1073
Copy link
Member Author

On a side note, I should have started hacking on matplotlib at least three years ago, this is a lot of fun.

@tacaswell tacaswell added this to the v1.5.x milestone Jan 19, 2015
@tacaswell
Copy link
Member

Looks good to me. This should probably be documented in https://github.com/matplotlib/matplotlib/tree/master/doc/api/api_changes .

👍 on re-using this in draw, the more we can reduce the size of the library the better.

@blink1073
Copy link
Member Author

Done on both fronts.

@tacaswell
Copy link
Member

This broke all of the builds


======================================================================
FAIL: matplotlib.tests.test_collections.test_polycollection_close.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 51, in failer
    result = f(*args, **kwargs)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 196, in do_test
    '(RMS %(rms).3f)'%err)
matplotlib.testing.noseclasses.ImageComparisonFailure: images not close: /home/travis/build/matplotlib/tmp_test_dir/result_images/test_collections/polycollection_close.png vs. /home/travis/build/matplotlib/tmp_test_dir/result_images/test_collections/polycollection_close-expected.png (RMS 16.460)

======================================================================
FAIL: matplotlib.tests.test_table.test_label_colours.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 51, in failer
    result = f(*args, **kwargs)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 196, in do_test
    '(RMS %(rms).3f)'%err)
matplotlib.testing.noseclasses.ImageComparisonFailure: images not close: /home/travis/build/matplotlib/tmp_test_dir/result_images/test_table/table_labels.png vs. /home/travis/build/matplotlib/tmp_test_dir/result_images/test_table/table_labels-expected.png (RMS 21.070)

======================================================================
FAIL: mpl_toolkits.tests.test_mplot3d.test_mixedsubplots.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 51, in failer
    result = f(*args, **kwargs)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 196, in do_test
    '(RMS %(rms).3f)'%err)
matplotlib.testing.noseclasses.ImageComparisonFailure: images not close: /home/travis/build/matplotlib/tmp_test_dir/result_images/test_mplot3d/mixedsubplot.png vs. /home/travis/build/matplotlib/tmp_test_dir/result_images/test_mplot3d/mixedsubplot-expected.png (RMS 13.760)

======================================================================
FAIL: mpl_toolkits.tests.test_mplot3d.test_mixedsubplots.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 51, in failer
    result = f(*args, **kwargs)
  File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/testing/decorators.py", line 196, in do_test
    '(RMS %(rms).3f)'%err)
matplotlib.testing.noseclasses.ImageComparisonFailure: images not close: /home/travis/build/matplotlib/tmp_test_dir/result_images/test_mplot3d/mixedsubplot_pdf.png vs. /home/travis/build/matplotlib/tmp_test_dir/result_images/test_mplot3d/mixedsubplot-expected_pdf.png (RMS 20.466)

@blink1073
Copy link
Member Author

Hopefully that does it.

@tacaswell
Copy link
Member

This is a change to a core-enough part of the library this needs to be looked at by at least a few more people.

cc @mdboom @efiring @WeatherGod @pelson

@blink1073
Copy link
Member Author

Ha! Drawing is a core part of the library?

@blink1073
Copy link
Member Author

(tongue in cheek of course)

@blink1073
Copy link
Member Author

Passes now (waiting on build docs, holy smokes it takes a while to build those suckers).

@blink1073 blink1073 changed the title Fix Axes get_children Order to Match draw Order Fix Axes get_children order to match draw order Jan 26, 2015
@tacaswell tacaswell modified the milestones: proposed next point release, next point release Feb 19, 2015
@efiring
Copy link
Member

efiring commented May 14, 2015

I like the idea of fixing the order in get_children(). Looking at this brings the following thought: it seems a little odd to have to get all of the children and then throw away half of them because they are special cases--the patch, the frame, etc. Would it make sense to let get_children() take an argument to determine whether it returns all children, or just the ones in a category? There seem to be two major categories: the artists directly associated with the Axes, and those that can be considered data. I haven't looked closely, so chances are I am missing something.

@tacaswell
Copy link
Member

@efiring I agree that makes sense, but want to punt on that to get this merged ASAP (so it gets some usage by the brave souls running master before we tag) .

It might be useful to let get_children (or a slightly differently named sibling method) take a function as an input so you could use it as a filter ex get_children(filter=lambda x : isinstance(x, Line2D)).

Explicitly tagging Artists as being 'infrastructure' or 'data' (or whatever) is probably something we should think about in the coming Great Artist Refactor of '15.

@WeatherGod
Copy link
Member

This sort of touches on a similar theme I raised in a PR (I don't have the
number on me), where I wanted to be able to select the order in which
elements of a collection are drawn. I did it by keeping a private attribute
that can be supplied to numpy arrays (so it can be indexes, slice or
boolean array). Maybe it could be generalizable?

On Fri, May 15, 2015 at 9:31 AM, Thomas A Caswell [email protected]
wrote:

@efiring https://github.com/efiring I agree that makes sense, but want
to punt on that to get this merged ASAP (so it gets some usage by the brave
souls running master before we tag) .

It might be useful to let get_children (or a slightly differently named
sibling method) take a function as an input so you could use it as a filter
ex get_children(filter=lambda x : isinstance(x, Line2D)).

Explicitly tagging Artists as being 'infrastructure' or 'data' (or
whatever) is probably something we should think about in the coming Great
Artist Refactor of '15.


Reply to this email directly or view it on GitHub
#4014 (comment)
.

efiring added a commit that referenced this pull request May 15, 2015
Fix Axes `get_children` order to match `draw` order
@efiring efiring merged commit 60eace2 into matplotlib:master May 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants