Skip to content

Backport PR #16648 on branch v3.2.x (Document filling of Poly3DCollection) #16763

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,17 +580,39 @@ def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
class Poly3DCollection(PolyCollection):
"""
A collection of 3D polygons.

.. note::
**Filling of 3D polygons**

There is no simple definition of the enclosed surface of a 3D polygon
unless the polygon is planar.

In practice, Matplotlib performs the filling on the 2D projection of
the polygon. This gives a correct filling appearance only for planar
polygons. For all other polygons, you'll find orientations in which
the edges of the polygon intersect in the projection. This will lead
to an incorrect visualization of the 3D area.

If you need filled areas, it is recommended to create them via
`~mpl_toolkits.mplot3d.axes3d.Axes3D.plot_trisurf`, which creates a
triangulation and thus generates consistent surfaces.
"""

def __init__(self, verts, *args, zsort='average', **kwargs):
"""
Create a Poly3DCollection.

*verts* should contain 3D coordinates.

Keyword arguments:
zsort, see set_zsort for options.
Parameters
----------
verts : list of array-like Nx3
Each element describes a polygon as a sequnce of ``N_i`` points
``(x, y, z)``.
zsort : {'average', 'min', 'max'}, default: 'average'
The calculation method for the z-order.
See `~.Poly3DCollection.set_zsort` for details.
*args, **kwargs
All other parameters are forwarded to `.PolyCollection`.

Notes
-----
Note that this class does a bit of magic with the _facecolors
and _edgecolors properties.
"""
Expand Down