@@ -3269,9 +3269,9 @@ def _map_face2color(face, colormap, vmin, vmax):
3269
3269
return face_color
3270
3270
3271
3271
@staticmethod
3272
- def _trisurf (x , y , z , simplices , show_colorbar , colormap = None ,
3273
- color_func = None , plot_edges = False , x_edge = None , y_edge = None ,
3274
- z_edge = None , facecolor = None ):
3272
+ def _trisurf (x , y , z , simplices , show_colorbar , edges_color ,
3273
+ colormap = None , color_func = None , plot_edges = False ,
3274
+ x_edge = None , y_edge = None , z_edge = None , facecolor = None ):
3275
3275
"""
3276
3276
Refer to FigureFactory.create_trisurf() for docstring
3277
3277
"""
@@ -3305,7 +3305,7 @@ def _trisurf(x, y, z, simplices, show_colorbar, colormap=None,
3305
3305
color_func [index ] = FigureFactory ._label_rgb (foo )
3306
3306
3307
3307
mean_dists = np .asarray (color_func )
3308
- else :
3308
+ elif hasattr ( color_func , '__call__' ) :
3309
3309
# apply user inputted function to calculate
3310
3310
# custom coloring for triangle vertices
3311
3311
mean_dists = []
@@ -3333,30 +3333,39 @@ def _trisurf(x, y, z, simplices, show_colorbar, colormap=None,
3333
3333
max_mean_dists )
3334
3334
facecolor .append (color )
3335
3335
3336
- # Make sure we have arrays to speed up plotting
3336
+ # Make sure facecolor is a list so output is consistent across Pythons
3337
3337
facecolor = list (facecolor )
3338
3338
ii , jj , kk = simplices .T
3339
3339
3340
- # make a colorscale from the colors
3341
- colorscale = FigureFactory ._make_colorscale (colormap )
3342
- colorscale = FigureFactory ._convert_colorscale_to_rgb (colorscale )
3343
-
3344
3340
triangles = graph_objs .Mesh3d (x = x , y = y , z = z , facecolor = facecolor ,
3345
3341
i = ii , j = jj , k = kk , name = '' )
3346
3342
3347
- colorbar = graph_objs .Mesh3d (x = [0 , 1 ], y = [0 , 1 ], z = [0 , 1 ],
3348
- colorscale = colorscale ,
3349
- intensity = [0 , 1 ],
3350
- showscale = True )
3343
+ if not isinstance (mean_dists [0 ], str ) and show_colorbar is True :
3344
+ # make a colorscale from the colors
3345
+ colorscale = FigureFactory ._make_colorscale (colormap )
3346
+ colorscale = FigureFactory ._convert_colorscale_to_rgb (colorscale )
3347
+
3348
+ colorbar = graph_objs .Scatter3d (
3349
+ x = x [:2 ],
3350
+ y = y [:2 ],
3351
+ z = z [:2 ],
3352
+ mode = 'markers' ,
3353
+ marker = dict (
3354
+ size = 0.1 ,
3355
+ color = [min_mean_dists , max_mean_dists ],
3356
+ colorscale = colorscale ,
3357
+ showscale = True ),
3358
+ hoverinfo = 'None' ,
3359
+ showlegend = False
3360
+ )
3351
3361
3352
3362
# the triangle sides are not plotted
3353
- if plot_edges is not True :
3354
- if show_colorbar is True :
3363
+ if plot_edges is False :
3364
+ if not isinstance ( mean_dists [ 0 ], str ) and show_colorbar is True :
3355
3365
return graph_objs .Data ([triangles , colorbar ])
3356
3366
else :
3357
3367
return graph_objs .Data ([triangles ])
3358
3368
3359
-
3360
3369
# define the lists x_edge, y_edge and z_edge, of x, y, resp z
3361
3370
# coordinates of edge end points for each triangle
3362
3371
# None separates data corresponding to two consecutive triangles
@@ -3392,10 +3401,14 @@ def _trisurf(x, y, z, simplices, show_colorbar, colormap=None,
3392
3401
# define the lines for plotting
3393
3402
lines = graph_objs .Scatter3d (
3394
3403
x = x_edge , y = y_edge , z = z_edge , mode = 'lines' ,
3395
- line = graph_objs .Line (color = 'rgb(50, 50, 50)' ,
3396
- width = 1.5 )
3404
+ line = graph_objs .Line (
3405
+ color = edges_color ,
3406
+ width = 1.5
3407
+ ),
3408
+ showlegend = False
3397
3409
)
3398
- if show_colorbar is True :
3410
+
3411
+ if not isinstance (mean_dists [0 ], str ) and show_colorbar is True :
3399
3412
return graph_objs .Data ([triangles , lines , colorbar ])
3400
3413
else :
3401
3414
return graph_objs .Data ([triangles , lines ])
@@ -3407,6 +3420,7 @@ def create_trisurf(x, y, z, simplices, colormap=None, show_colorbar=True,
3407
3420
backgroundcolor = 'rgb(230, 230, 230)' ,
3408
3421
gridcolor = 'rgb(255, 255, 255)' ,
3409
3422
zerolinecolor = 'rgb(255, 255, 255)' ,
3423
+ edges_color = 'rgb(50, 50, 50)' ,
3410
3424
height = 800 , width = 800 ,
3411
3425
aspectratio = dict (x = 1 , y = 1 , z = 1 )):
3412
3426
"""
@@ -3440,6 +3454,7 @@ def create_trisurf(x, y, z, simplices, colormap=None, show_colorbar=True,
3440
3454
inclusive
3441
3455
:param (str) zerolinecolor: color of the axes. Takes a string of the
3442
3456
form 'rgb(x,y,z)' x,y,z are between 0 and 255 inclusive
3457
+ :param (str) edges_color: color of the edges, if plot_edges is True
3443
3458
:param (int|float) height: the height of the plot (in pixels)
3444
3459
:param (int|float) width: the width of the plot (in pixels)
3445
3460
:param (dict) aspectratio: a dictionary of the aspect ratio values for
@@ -3622,6 +3637,7 @@ def dist_origin(x, y, z):
3622
3637
x, y, z, simplices,
3623
3638
color_func=colors,
3624
3639
show_colorbar=True,
3640
+ edges_color='rgb(2,85,180)',
3625
3641
title=' Modern Art'
3626
3642
)
3627
3643
@@ -3637,6 +3653,7 @@ def dist_origin(x, y, z):
3637
3653
show_colorbar = show_colorbar ,
3638
3654
color_func = color_func ,
3639
3655
colormap = colormap ,
3656
+ edges_color = edges_color ,
3640
3657
plot_edges = plot_edges )
3641
3658
axis = dict (
3642
3659
showbackground = showbackground ,
0 commit comments