changing the color of a node

613 views
Skip to first unread message

elvis...@gmail.com

unread,
Feb 24, 2022, 9:10:55 AM2/24/22
to networkx-discuss
Hi, 

while processing a graph and identifying nodes of intrest, I want to change the color of those nodes (or even 1 node).  I am encountering issues in the sense that 

nx.set_node_attributes(graph, {end_name: "red"}, name="color")

from that end-name is the name of the node for which i want to chage the color. 

any idea how to do this ?

Thanks,
Elvis

Dan Schult

unread,
Feb 24, 2022, 9:30:26 AM2/24/22
to networkx...@googlegroups.com
A more direct way to change that data attribute for a single node is:

G.nodes[endnode]["color"] = "red"

To actually see the color when you plot the network, you will need to tell the
drawing routine what attribute you will use for indicating color and you probably
want to make sure that all nodes have that attribute (though it can work without that).

Elvis Shera

unread,
Feb 24, 2022, 9:40:14 AM2/24/22
to networkx...@googlegroups.com
Thank you,

For costumes attributes seems working but as you say for the plotting routine I need to tell this.

Elvis

--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/networkx-discuss/CA%2BXMcTMJeDkVJADz-4vm--4S_VUzE5aN9%3DYeSE3NUOfRXFp2Vw%40mail.gmail.com.
--
Best Regards / Freundlichen Grüßen,
Elvis Shera

Elvis Shera

unread,
Feb 25, 2022, 5:35:10 AM2/25/22
to networkx...@googlegroups.com
is there a way such that i can tell to the drawing routine to fo and take the color and width etc.. directly from the corresponding attributes stored in the node object itself ?

Thanks,
Elvis

--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/networkx-discuss/CA%2BXMcTMJeDkVJADz-4vm--4S_VUzE5aN9%3DYeSE3NUOfRXFp2Vw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages