In my case, I had 2 groups of nodes (from sklearn.model_selection import train_test_split
). I wanted to change the color of each group (default color are awful!). It took me while to figure it out how to change it but, Tensor is numpy based and Matplotlib is the core of networkx
library. Therefore ...
test=data.y
test=test.numpy()
test=test.astype(np.str_)
test[test == '0'] = '#C6442A'
test[test == '1'] = '#9E2AC6'
nx.draw(G, with_labels=True, node_color=test, node_size=400, font_color='whitesmoke')
Long story short: convert the Tensor in numpy array with string type, check your best Hex color codes for HTML (https://htmlcolorcodes.com/) and you are ready to go!