Whilst drawing a networkx graph, with differently coloured nodes, I'm trying to make some of them transparent. Based on the last
CodePudding user response:
Two alternatives to the method you've chosen are described below:
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 ofcolors.to_rgba()
though), then append your desired alpha value to the end of the tuple using the method described in this answer.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 tonode_color
and a list of alpha values toalpha
. With thecolour_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.