Reputation: 125
I have looked a bit into the node_color
keyword parameter of the nx.draw()
method. Here are two different graphs colored using node_colors
.
node_colors = [.5,.5,0.,1.]
. Colors appear as expected
node_colors = [.9,1.,1.,1.]
. Colors do not appear as expected
In the second image, I would expect the color of node 1 to be almost as dark. I assume what is happening is the colormap is getting scaled from the minimum value to the maximum value. For the first example, that's fine, but how can I set the colormap to be scaled from: 0=white, 1=blue every time?
Upvotes: 1
Views: 522
Reputation: 23907
You are correct about the cause of the problem. To fix it, you need to define vmin
and vmax
.
I believe
nx.draw(G, node_color=[0.9,1.,1.,1.], vmin=0, vmax=1)
will do what you're after (I would need to know what colormap you're using to be sure).
For edges, there are similar parameters: edge_vmin
and edge_vmax
.
Upvotes: 2