@@ -299,6 +299,8 @@ def _plot_graph(G, vertex_color, vertex_size, highlight,
299299 Signal to plot as vertex color (length is the number of vertices).
300300 If None, vertex color is set to `graph.plotting['vertex_color']`.
301301 Alternatively, a color can be set in any format accepted by matplotlib.
302+ Each vertex color can by specified by an RGB(A) array of dimension
303+ `n_vertices` x 3 (or 4).
302304 vertex_size : array-like or int
303305 Signal to plot as vertex size (length is the number of vertices).
304306 Vertex size ranges from 0.5 to 2 times `graph.plotting['vertex_size']`.
@@ -319,6 +321,8 @@ def _plot_graph(G, vertex_color, vertex_size, highlight,
319321 ranges from 0.2 to 0.9.
320322 If None, edge color is set to `graph.plotting['edge_color']`.
321323 Alternatively, a color can be set in any format accepted by matplotlib.
324+ Each edge color can by specified by an RGB(A) array of dimension
325+ `n_edges` x 3 (or 4).
322326 Only available with the matplotlib backend.
323327 edge_width : array-like or int
324328 Signal to plot as edge width (length is the number of edges).
@@ -405,20 +409,26 @@ def normalize(x):
405409 return np .full (x .shape , 0.5 )
406410 return 0.75 * (x - x .min ()) / ptp + 0.25
407411
408- def is_single_color (color ):
412+ def is_color (color ):
413+
409414 if backend == 'matplotlib' :
410415 mpl , _ , _ = _import_plt ()
411- return mpl .colors .is_color_like (color )
412- elif backend == 'pyqtgraph' :
413- # No support (yet) for single color with pyqtgraph.
414- return False
416+ if mpl .colors .is_color_like (color ):
417+ return True # single color
418+ try :
419+ return all (map (mpl .colors .is_color_like , color )) # color list
420+ except TypeError :
421+ return False # e.g., color is an int
422+
423+ else :
424+ return False # No support for pyqtgraph (yet).
415425
416426 if vertex_color is None :
417427 limits = [0 , 0 ]
418428 colorbar = False
419429 if backend == 'matplotlib' :
420430 vertex_color = (G .plotting ['vertex_color' ],)
421- elif is_single_color (vertex_color ):
431+ elif is_color (vertex_color ):
422432 limits = [0 , 0 ]
423433 colorbar = False
424434 else :
@@ -438,8 +448,8 @@ def is_single_color(color):
438448
439449 if edge_color is None :
440450 edge_color = (G .plotting ['edge_color' ],)
441- elif not is_single_color (edge_color ):
442- edge_color = np .array (edge_color ).squeeze ()
451+ elif not is_color (edge_color ):
452+ edge_color = np .asarray (edge_color ).squeeze ()
443453 check_shape (edge_color , 'Edge color' , G .n_edges )
444454 edge_color = 0.9 * normalize (edge_color )
445455 edge_color = [
0 commit comments