@@ -1562,7 +1562,7 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
1562
1562
1563
1563
return linec
1564
1564
1565
- def plot_trisurf (self , X , Y , Z , * args , ** kwargs ):
1565
+ def plot_trisurf (self , * args , ** kwargs ):
1566
1566
"""
1567
1567
============= ================================================
1568
1568
Argument Description
@@ -1576,9 +1576,37 @@ def plot_trisurf(self, X, Y, Z, *args, **kwargs):
1576
1576
*shade* Whether to shade the facecolors
1577
1577
============= ================================================
1578
1578
1579
+ The (optional) triangulation can be specified in one of two ways;
1580
+ either::
1581
+
1582
+ plot_trisurf(triangulation, ...)
1583
+
1584
+ where triangulation is a :class:`~matplotlib.tri.Triangulation`
1585
+ object, or::
1586
+
1587
+ plot_trisurf(X, Y, ...)
1588
+ plot_trisurf(X, Y, triangles, ...)
1589
+ plot_trisurf(X, Y, triangles=triangles, ...)
1590
+
1591
+ in which case a Triangulation object will be created. See
1592
+ :class:`~matplotlib.tri.Triangulation` for a explanation of
1593
+ these possibilities.
1594
+
1595
+ The remaining arguments are::
1596
+
1597
+ plot_trisurf(..., Z)
1598
+
1599
+ where *Z* is the array of values to contour, one per point
1600
+ in the triangulation.
1601
+
1579
1602
Other arguments are passed on to
1580
1603
:class:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
1581
1604
1605
+ **Examples:**
1606
+
1607
+ .. plot:: mpl_examples/mplot3d/trisurf3d_demo.py
1608
+ .. plot:: mpl_examples/mplot3d/trisurf3d_demo2.py
1609
+
1582
1610
.. versionadded:: 1.2.0
1583
1611
This plotting function was added for the v1.2.0 release.
1584
1612
"""
@@ -1596,15 +1624,13 @@ def plot_trisurf(self, X, Y, Z, *args, **kwargs):
1596
1624
shade = kwargs .pop ('shade' , cmap is None )
1597
1625
lightsource = kwargs .pop ('lightsource' , None )
1598
1626
1599
- # TODO: Support masked triangulations
1600
- tri = Triangulation (X , Y )
1601
- x = tri .x
1602
- y = tri .y
1603
- triangles = tri .triangles
1627
+ tri , args , kwargs = Triangulation .get_from_args_and_kwargs (* args , ** kwargs )
1628
+ z = np .asarray (args [0 ])
1604
1629
1605
- xt = x [triangles ][...,np .newaxis ]
1606
- yt = y [triangles ][...,np .newaxis ]
9D6F
div>
1607
- zt = np .array (Z )[triangles ][...,np .newaxis ]
1630
+ triangles = tri .get_masked_triangles ()
1631
+ xt = tri .x [triangles ][...,np .newaxis ]
1632
+ yt = tri .y [triangles ][...,np .newaxis ]
1633
+ zt = np .array (z )[triangles ][...,np .newaxis ]
1608
1634
1609
1635
verts = np .concatenate ((xt , yt , zt ), axis = 2 )
1610
1636
@@ -1649,7 +1675,7 @@ def plot_trisurf(self, X, Y, Z, *args, **kwargs):
1649
1675
polyc .set_facecolors (colset )
1650
1676
1651
1677
self .add_collection (polyc )
1652
- self .auto_scale_xyz (X , Y , Z , had_data )
1678
+ self .auto_scale_xyz (tri . x , tri . y , z , had_data )
1653
1679
1654
1680
return polyc
1655
1681
0 commit comments