☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

From_networkx telling my that dict isn't callable even though documentation says that "layout_function" accepts a dictionary

Community Support
commanderjack
commanderjack

I’m trying to plot nodes based on XY coordinates. Here’s what I have so far:

points = {0: (45638.801, 55742.448),
 1: (53717.677, 53637.007),
 2: (45670.461, 58929.536),
 3: (54683.019, 58581.992)}

G = nx.Graph()
G.add_nodes_from([0,len(points)-1])

plot = Plot(width=800, height=800)

graph_renderer = from_networkx(G, points)

But when I run this, I get the following error:

TypeError: 'dict' object is not callable

However, the documentation states that the layout_function parameter can accept a dictionary.

⌁   Link to post
commanderjack
commanderjack

Working on determining the package version; it’s entirely possible that I have Python downloaded twice on my work computer.

…stacktrace? I’m unfamiliar with that term.

Edit: this guy?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-159-fa2797099a87> in <module>()
     11 
     12 #graph_renderer = from_networkx(G, nx.circular_layout, scale=1, center=(0,0))
---> 13 graph_renderer = from_networkx(G, points)
     14 
     15 graph_renderer.node_renderer.glyph = Circle(size=15, fill_color=Spectral4[0])

C:\Work\Anaconda\lib\site-packages\bokeh\models\graphs.py in from_networkx(graph, layout_function, **kwargs)
     72         graph_renderer.edge_renderer.data_source.data = edge_source.data
     73 
---> 74         graph_layout = layout_function(graph, **kwargs)
     75         graph_renderer.layout_provider = StaticLayoutProvider(graph_layout=graph_layout)
     76 

TypeError: 'dict' object is not callable
⌁   Link to post
Bryan
Bryan

You would have to be running a considerably ancient version of Bokeh (0.13 or less) to explain that stack trace. If that is the case, the docs you are looking at are too new, since the ability to pass a dict was a feature added after the 1.0 release. Most of the graph interaction polices also probably don’t exist in 0.13 either (I would guess… it was almost half a decade ago). For reference, Bokeh 3.0 is due to be released soon.

In any case it’s important to refer to docs relevant to the actual release you have installed, especially the older the release is. FYI you can generally get to any version of docs, even if they are not explicitly listed in the dropdown at the top of the page: https://docs.bokeh.org/en/0.13.0/

⌁   Link to post

End of archived discussion · Replies are disabled