@@ -57,7 +57,7 @@ def plot_plotly(
5757 mapper_plot ,
5858 width : int ,
5959 height : int ,
60- node_size : int = DEFAULT_NODE_SIZE ,
60+ node_size : Optional [ Union [ int , List [ int ]]] = DEFAULT_NODE_SIZE ,
6161 colors = None ,
6262 title : Optional [Union [str , List [str ]]] = None ,
6363 agg = np .nanmean ,
@@ -73,8 +73,9 @@ def plot_plotly(
7373 titles = [title for _ in range (colors_num )]
7474 elif isinstance (title , list ) and len (title ) == colors_num :
7575 titles = title
76- fig = _figure (mapper_plot , width , height , node_size , colors , titles , agg , cmaps )
77- _add_ui_to_layout (mapper_plot , fig , colors , titles , node_size , agg , cmaps )
76+ node_sizes = [node_size ] if isinstance (node_size , int ) else node_size
77+ fig = _figure (mapper_plot , width , height , node_sizes , colors , titles , agg , cmaps )
78+ _add_ui_to_layout (mapper_plot , fig , colors , titles , node_sizes , agg , cmaps )
7879 return fig
7980
8081
@@ -220,7 +221,7 @@ def _update_layout(fig, width, height):
220221 )
221222
222223
223- def _figure (mapper_plot , width , height , node_size , colors , titles , agg , cmaps ):
224+ def _figure (mapper_plot , width , height , node_sizes , colors , titles , agg , cmaps ):
224225 node_pos = mapper_plot .positions
225226 node_pos_arr = _node_pos_array (
226227 mapper_plot .graph ,
@@ -239,7 +240,7 @@ def _figure(mapper_plot, width, height, node_size, colors, titles, agg, cmaps):
239240
240241 _set_cmap (mapper_plot , fig , cmaps [0 ])
241242 _set_colors (mapper_plot , fig , colors [:, 0 ], agg )
242- _set_node_size (mapper_plot , fig , node_size )
243+ _set_node_size (mapper_plot , fig , node_sizes [ len ( node_sizes ) // 2 ] )
243244 _set_title (mapper_plot , fig , titles [0 ])
244245
245246 return fig
@@ -387,7 +388,7 @@ def _layout(width, height):
387388 )
388389
389390
390- def _add_ui_to_layout (mapper_plot , mapper_fig , colors , titles , node_size , agg , cmaps ):
391+ def _add_ui_to_layout (mapper_plot , mapper_fig , colors , titles , node_sizes , agg , cmaps ):
391392 cmaps_plotly = [PLOTLY_CMAPS .get (c .lower ()) for c in cmaps ]
392393 menu_color = _ui_color (mapper_plot , colors , titles , agg )
393394 if menu_color ["buttons" ]:
@@ -396,7 +397,7 @@ def _add_ui_to_layout(mapper_plot, mapper_fig, colors, titles, node_size, agg, c
396397 menu_color ["x" ] = - 0.25
397398 menu_cmap = _ui_cmap (mapper_plot , cmaps_plotly )
398399 menu_cmap ["x" ] = menu_color ["x" ] + 0.25
399- slider_size = _ui_node_size (mapper_plot , node_size )
400+ slider_size = _ui_node_size (mapper_plot , node_sizes )
400401 mapper_fig .update_layout (
401402 updatemenus = [menu_cmap , menu_color ],
402403 sliders = [slider_size ],
@@ -441,7 +442,7 @@ def _update_cmap(cmap):
441442 )
442443
443444
444- def _ui_node_size (mapper_plot , node_size ):
445+ def _ui_node_size (mapper_plot , node_sizes ):
445446 steps = [
446447 dict (
447448 method = "restyle" ,
@@ -451,7 +452,7 @@ def _ui_node_size(mapper_plot, node_size):
451452 [1 ],
452453 ],
453454 )
454- for size in [ node_size * x / 10.0 for x in range ( 1 , 20 )]
455+ for size in node_sizes
455456 ]
456457
457458 return dict (
0 commit comments