Whilst drawing a networkx graph, with differently coloured nodes, I'm trying to make some of them transparent. Based on the last answer in this post, that seems to be possible. However, I am experiencing some difficulties in setting both the colour, and the transparency value.
Analog to the given answer in the linked post, I tried:
for node_name in G.nodes:
if node_name[:4] == "red_":
colour_dict[node_name] = ["olive",0.5]
else:
colour_dict[node_name] = ["yellow",1]
nx.draw(
G,
nx.get_node_attributes(G, "pos"),
with_labels=True,
node_size=160,
font_size=6,
width=0.2,
node_color=color_map,
edge_color=edge_color_map,
# **options,
)
Which returns:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not [['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1], ['olive', 1]]
Hence, I would like to ask, how can one set the node colour and make it transparent (e.g. 50% transparent) at the same time?