@@ -1533,9 +1533,14 @@ def _trisurf(x, y, z, simplices, colormap=None, color_func=None,
1533
1533
# vertices of the surface triangles
1534
1534
tri_vertices = points3D [simplices ]
1535
1535
1536
- if not color_func :
1536
+ if color_func is None :
1537
1537
# mean values of z-coordinates of triangle vertices
1538
1538
mean_dists = tri_vertices [:, :, 2 ].mean (- 1 )
1539
+ elif isinstance (color_func , (list , np .ndarray )):
1540
+ if len (color_func ) != len (simplices ):
1541
+ raise ValueError ('If color_func is a list/array, must'
1542
+ ' be the same length as simplices' )
1543
+ mean_dists = color_func
1539
1544
else :
1540
1545
# apply user inputted function to calculate
1541
1546
# custom coloring for triangle vertices
@@ -1548,13 +1553,15 @@ def _trisurf(x, y, z, simplices, colormap=None, color_func=None,
1548
1553
dists .append (dist )
1549
1554
1550
1555
mean_dists .append (np .mean (dists ))
1551
-
1552
- min_mean_dists = np .min (mean_dists )
1553
- max_mean_dists = np .max (mean_dists )
1554
- facecolor = FigureFactory ._map_z2color (mean_dists ,
1555
- colormap ,
1556
- min_mean_dists ,
1557
- max_mean_dists )
1556
+ if isinstance (mean_dists [0 ], str ):
1557
+ facecolor = mean_dists
1558
+ else :
1559
+ min_mean_dists = np .min (mean_dists )
1560
+ max_mean_dists = np .max (mean_dists )
1561
+ facecolor = FigureFactory ._map_z2color (mean_dists ,
1562
+ colormap ,
1563
+ min_mean_dists ,
1564
+ max_mean_dists )
1558
1565
1559
1566
ii , jj , kk = zip (* simplices )
1560
1567
triangles = graph_objs .Mesh3d (x = x , y = y , z = z , facecolor = facecolor ,
0 commit comments