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: size and color rendering for Path3DCollection#19812

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
QuLogic merged 1 commit intomatplotlib:masterfromtacaswell:fix_scatter3D
Mar 31, 2021

Conversation

tacaswell
Copy link
Member

PR Summary

This fixes both bugs identified in#19787

Still needs test and the tactic should be expanded to the other *Collections before we merge.

@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelMar 29, 2021
@tacaswelltacaswell added this to thev3.4.1 milestoneMar 29, 2021
@tacaswelltacaswell marked this pull request as ready for reviewMarch 30, 2021 22:42
@jklymak
Copy link
Member

Looks like a real doc-build failure.... :-(

generating gallery for gallery/mplot3d... [  2%] 2dcollections3d.pyWARNING: /home/circleci/project/examples/mplot3d/2dcollections3d.py failed to execute correctly: Traceback (most recent call last):  File "/home/circleci/project/examples/mplot3d/2dcollections3d.py", line 36, in <module>    ax.legend()  File "/home/circleci/project/lib/matplotlib/axes/_axes.py", line 290, in legend    self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)  File "/home/circleci/project/lib/matplotlib/legend.py", line 503, in __init__    self._init_legend_box(handles, labels, markerfirst)  File "/home/circleci/project/lib/matplotlib/legend.py", line 766, in _init_legend_box    handle_list.append(handler.legend_artist(self, orig_handle,  File "/home/circleci/project/lib/matplotlib/legend_handler.py", line 115, in legend_artist    artists = self.create_artists(legend, orig_handle,  File "/home/circleci/project/lib/matplotlib/legend_handler.py", line 447, in create_artists    p = self.create_collection(orig_handle, sizes,  File "/home/circleci/project/lib/matplotlib/legend_handler.py", line 459, in create_collection    p = type(orig_handle)([orig_handle.get_paths()[0]],  File "/home/circleci/project/lib/mpl_toolkits/mplot3d/art3d.py", line 525, in __init__    super().__init__(*args, **kwargs)  File "/home/circleci/project/lib/matplotlib/collections.py", line 1029, in __init__    super().__init__(**kwargs)  File "/home/circleci/project/lib/matplotlib/_api/deprecation.py", line 421, in wrapper    return func(*inner_args, **inner_kwargs)  File "/home/circleci/project/lib/matplotlib/collections.py", line 180, in __init__    self.set_linewidth(linewidths)  File "/home/circleci/project/lib/mpl_toolkits/mplot3d/art3d.py", line 570, in set_linewidth    if not self._in_draw:AttributeError: 'Path3DCollection' object has no attribute '_in_draw'

@tacaswell
Copy link
MemberAuthor

I was thinking about the fix@QuLogic put in for#18916 and was wondering if that was going to come back in other ways and it did!

@tacaswell
Copy link
MemberAuthor

No, I jumped to conclusion, but it is an easy fix. Running a full docs build locally before pushing.

@QuLogic
Copy link
Member

I think you're running into the same issue as#18932 did, namely that legend copies the class, and so creates a 3D collection for its legend handle, without doing any of the 3D work.

@tacaswell
Copy link
MemberAuthor

I think this is slightly different, the problem is it isactually creating a the 3D class, rather than the slightly-upsetting

defpatch_collection_2d_to_3d(col,zs=0,zdir='z',depthshade=True):
"""
Convert a :class:`~matplotlib.collections.PatchCollection` into a
:class:`Patch3DCollection` object
(or a :class:`~matplotlib.collections.PathCollection` into a
:class:`Path3DCollection` object).
Parameters
----------
za
The location or locations to place the patches in the collection along
the *zdir* axis. Default: 0.
zdir
The axis in which to place the patches. Default: "z".
depthshade
Whether to shade the patches to give a sense of depth. Default: *True*.
"""
ifisinstance(col,PathCollection):
col.__class__=Path3DCollection
elifisinstance(col,PatchCollection):
col.__class__=Patch3DCollection
col._depthshade=depthshade
col.set_3d_properties(zs,zdir)
so in the case of scatter we were creating it via the 3d props call, but in the scatter case we were running the__init__ which bounced to the super class which tries to set the linewidth before setup the 3D stuff.

@tacaswell
Copy link
MemberAuthor

Going to make an executive decision and say that@QuLogic can merge this on one review so we can get 3.4.1 out.

Copy link
Member

@QuLogicQuLogic left a comment

Choose a reason for hiding this comment

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

I have minor comments, and I'll leave this open for a little bit in case anyone else is able to review.

Thisfixesmatplotlib#19787This modifies the way we manage internal depth sorting of elements in the 3Dcollections.  We need to both preserve the original order (so we can keep theposition, size, colour, ... in sync), but present each of them to the 2Drendering code in depth order (back to front).  In some cases we can handlethis by sorting the values in the getter methods and in others we have to keepa cache of both the sorted (the names used by the 2D code) andunsorted (post-fixed with 3d) data.It does not appear that Line3DCollection does any of the z-sorting that theother collections do.  While definitely a limitation and produces MC Eschereffects, this is out of scope of the current work.The z-sorting on Poly3DCollection is significantly more sophisticated than thesorting on Path3DCollection and Patch3DCollection so it is handleddifferently.Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@QuLogicQuLogic merged commitee9500a intomatplotlib:masterMar 31, 2021
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMar 31, 2021
QuLogic added a commit that referenced this pull requestMar 31, 2021
Backport PR#19812: FIX: size and color rendering for Path3DCollection
@tacaswelltacaswell deleted the fix_scatter3D branchMarch 31, 2021 13:36
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v3.4.1
Development

Successfully merging this pull request may close these issues.

3 participants
@tacaswell@jklymak@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp