While working with NetworkX, I managed to plot a graph that shows the node size corresponding to a node attribute. To produce a consistent plot, I want to show the node size in the legend. Is there a pre-implemented way to add a legend with a defined number (e.g., four) of node sizes with the corresponding node attribute?
I imagine something similar to the appended legend.
CodePudding user response:
I am unsure of a built-in way to do this, but networkx
plotting algorithm uses scatter
to set node size so you can create a set of ghost nodes using scatter that are used in the legend. (I am making up the term ghost because you don't actually see them. There may be an officially accepted term, I don't know.)
For some reason I am could not get these to work with scatter
so I am using plot
instead. (Note that the size of values in scatter
follows area while plot
follows width