Home > Net >  Transparant, and coloured, networkx nodes with a node colour dictionary?
Transparant, and coloured, networkx nodes with a node colour dictionary?

Time:12-13

Whilst drawing a networkx graph, with differently coloured nodes, I'm trying to make some of them transparent. Based on the last enter image description here

CodePudding user response:

Two alternatives to the method you've chosen are described below:

  1. Rather than searching for rgb values for your desired colors, you could use the method shown in this answer to get the rgb value of the named color (just use colors.to_rgb() instead of colors.to_rgba() though), then append your desired alpha value to the end of the tuple using the method described in this answer.

  2. It may be more convenient to draw the nodes separately using nx.draw_networkx_nodes By doing so, you can pass in a list of colors to node_color and a list of alpha values to alpha. With the colour_dict that you've defined, you can easily create these lists to pass into the drawing function. You can find more details in this question and answer if you'd like.

  • Related