Legend in network graph

Hi!

I am trying to assign a legend to a network in such a way that the information of the colors of nodes and arcs is established.

I’ve tried

import networkx as nx

from bokeh.io import output_file, show
from bokeh.models import CustomJSTransform, LabelSet
from bokeh.models import Legend, LegendItem
from bokeh.plotting import figure, from_networkx

G=nx.nx.barbell_graph(3,2)

p = figure(x_range=(-3,3), y_range=(-3,3))
p.grid.grid_line_color = None

r = from_networkx(G, nx.spring_layout, scale=3, center=(0,0))
r.node_renderer.glyph.size=15
r.edge_renderer.glyph.line_alpha=0.2

p.renderers.append(r)
legend = Legend(items=[
    LegendItem(label="orange", renderers=[r.node_renderer])])
p.add_layout(legend)
show(p)

Thanks

The above code generates the picture below, which is exactly what I would expect:

Screen Shot 2021-02-12 at 12.48.52 PM

If you change the node fill color:

r.node_renderer.glyph.fill_color="red"

Then the legend also changes correspondingly:

Screen Shot 2021-02-12 at 12.50.11 PM

which is also exactly what I would expect. You will need to describe what you are trying to accomplish in much more detail.