@@ -299,6 +299,8 @@ def _plot_graph(G, vertex_color, vertex_size, highlight,
299
299
Signal to plot as vertex color (length is the number of vertices).
300
300
If None, vertex color is set to `graph.plotting['vertex_color']`.
301
301
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).
302
304
vertex_size : array-like or int
303
305
Signal to plot as vertex size (length is the number of vertices).
304
306
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,
319
321
ranges from 0.2 to 0.9.
320
322
If None, edge color is set to `graph.plotting['edge_color']`.
321
323
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).
322
326
Only available with the matplotlib backend.
323
327
edge_width : array-like or int
324
328
Signal to plot as edge width (length is the number of edges).
@@ -405,20 +409,26 @@ def normalize(x):
405
409
return np .full (x .shape , 0.5 )
406
410
return 0.75 * (x - x .min ()) / ptp + 0.25
407
411
408
- def is_single_color (color ):
412
+ def is_color (color ):
413
+
409
414
if backend == 'matplotlib' :
410
415
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).
415
425
416
426
if vertex_color is None :
417
427
limits = [0 , 0 ]
418
428
colorbar = False
419
429
if backend == 'matplotlib' :
420
430
vertex_color = (G .plotting ['vertex_color' ],)
421
- elif is_single_color (vertex_color ):
431
+ elif is_color (vertex_color ):
422
432
limits = [0 , 0 ]
423
433
colorbar = False
424
434
else :
@@ -438,8 +448,8 @@ def is_single_color(color):
438
448
439
449
if edge_color is None :
440
450
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 ()
443
453
check_shape (edge_color , 'Edge color' , G .n_edges )
444
454
edge_color = 0.9 * normalize (edge_color )
445
455
edge_color = [
0 commit comments