@@ -1517,8 +1517,8 @@ def _map_z2color(zvals, colormap, vmin, vmax):
1517
1517
return labelled_colors
1518
1518
1519
1519
@staticmethod
1520
- def _trisurf (x , y , z , simplices , colormap = None , dist_func = None ,
1521
- plot_edges = None , x_edge = None , y_edge = None , z_edge = None ):
1520
+ def _trisurf (x , y , z , simplices , colormap = None , color_func = None ,
1521
+ plot_edges = False , x_edge = None , y_edge = None , z_edge = None ):
1522
1522
"""
1523
1523
Refer to FigureFactory.create_trisurf() for docstring
1524
1524
"""
@@ -1533,7 +1533,7 @@ def _trisurf(x, y, z, simplices, colormap=None, dist_func=None,
1533
1533
# vertices of the surface triangles
1534
1534
tri_vertices = points3D [simplices ]
1535
1535
1536
- if not dist_func :
1536
+ if not color_func :
1537
1537
# mean values of z-coordinates of triangle vertices
1538
1538
mean_dists = tri_vertices [:, :, 2 ].mean (- 1 )
1539
1539
else :
@@ -1544,17 +1544,19 @@ def _trisurf(x, y, z, simplices, colormap=None, dist_func=None,
1544
1544
for triangle in tri_vertices :
1545
1545
dists = []
1546
1546
for vertex in triangle :
1547
- dist = dist_func (vertex [0 ], vertex [1 ], vertex [2 ])
1547
+ dist = color_func (vertex [0 ], vertex [1 ], vertex [2 ])
1548
1548
dists .append (dist )
1549
1549
1550
1550
mean_dists .append (np .mean (dists ))
1551
1551
1552
1552
min_mean_dists = np .min (mean_dists )
1553
1553
max_mean_dists = np .max (mean_dists )
1554
- facecolor = FigureFactory ._map_z2color (mean_dists , colormap ,
1555
- min_mean_dists , max_mean_dists )
1556
- ii , jj , kk = zip (* simplices )
1554
+ facecolor = FigureFactory ._map_z2color (mean_dists ,
1555
+ colormap ,
1556
+ min_mean_dists ,
1557
+ max_mean_dists )
1557
1558
1559
+ ii , jj , kk = zip (* simplices )
1558
1560
triangles = graph_objs .Mesh3d (x = x , y = y , z = z , facecolor = facecolor ,
1559
1561
i = ii , j = jj , k = kk , name = '' )
1560
1562
@@ -1603,8 +1605,8 @@ def _trisurf(x, y, z, simplices, colormap=None, dist_func=None,
1603
1605
return graph_objs .Data ([triangles , lines ])
1604
1606
1605
1607
@staticmethod
1606
- def create_trisurf (x , y , z , simplices , colormap = None ,
1607
- dist_func = None , title = 'Trisurf Plot' ,
1608
+ def create_trisurf (x , y , z , simplices , colormap = None , color_func = None ,
1609
+ title = 'Trisurf Plot' , plot_edges = True ,
1608
1610
showbackground = True ,
1609
1611
backgroundcolor = 'rgb(230, 230, 230)' ,
1610
1612
gridcolor = 'rgb(255, 255, 255)' ,
@@ -1624,12 +1626,13 @@ def create_trisurf(x, y, z, simplices, colormap=None,
1624
1626
containing 2 triplets. These triplets must be of the form (a,b,c)
1625
1627
or 'rgb(x,y,z)' where a,b,c belong to the interval [0,1] and x,y,z
1626
1628
belong to [0,255]
1627
- :param (function) dist_func: The function that determines how the
1628
- coloring of the surface changes. It takes 3 arguments x, y, z and
1629
- must return a formula of these variables which can include numpy
1630
- functions (eg. np.sqrt). If set to None, color will only depend on
1631
- the z axis.
1629
+ :param (function|list) color_func: The parameter that determines the
1630
+ coloring of the surface. Takes either a function with 3 arguments
1631
+ x, y, z or a list/array of color values the same length as
1632
+ simplices. If set to None, color will only depend on the z axis.
1632
1633
:param (str) title: title of the plot
1634
+ :param (bool) plot_edges: determines if the triangles on the trisurf
1635
+ are visible
1633
1636
:param (bool) showbackground: makes background in plot visible
1634
1637
:param (str) backgroundcolor: color of background. Takes a string of
1635
1638
the form 'rgb(x,y,z)' x,y,z are between 0 and 255 inclusive.
@@ -1776,7 +1779,7 @@ def dist_origin(x, y, z):
1776
1779
fig1 = FF.create_trisurf(x=x, y=y, z=z,
1777
1780
colormap="Blues",
1778
1781
simplices=simplices,
1779
- dist_func =dist_origin)
1782
+ color_func =dist_origin)
1780
1783
# Plot the data
1781
1784
py.iplot(fig1, filename='Trisurf Plot - Custom Coloring')
1782
1785
```
@@ -1851,9 +1854,9 @@ def dist_origin(x, y, z):
1851
1854
"exceed 1.0." )
1852
1855
1853
1856
data1 = FigureFactory ._trisurf (x , y , z , simplices ,
1854
- dist_func = dist_func ,
1857
+ color_func = color_func ,
1855
1858
colormap = colormap ,
1856
- plot_edges = True )
1859
+ plot_edges = plot_edges )
1857
1860
axis = dict (
1858
1861
showbackground = showbackground ,
1859
1862
backgroundcolor = backgroundcolor ,
0 commit comments