Support for Networkx, Pyvis and Folium

Hi Team,

Was wondering if there is an easy way to render Folium maps or Pyvis graphs(imported from networkx). Also if these graphs are saved as .html files is there a way to render them inside the app?

regards,
Aravind

2 Likes

Hi Aravind_K_R — that’s a great question

While we don’t support Folium or Pyvis right now, we’re always looking for new libraries to support. These sound like great candidates.

In the meantime, depending on what you want to do it’s possible you could use st.deck_gl_chart in place of Folium, and st.graphviz_chart to render networkx graphs in place of Pyvis.

Here’s the documentation for st.deck_gl_chart: https://streamlit.io/docs/api.html#streamlit.deck_gl_chart
To see some of the things it can do, check out the mapping demo in streamlit hello, which includes sample code as well.

As for st.graphviz_chart, here’s how you can use it with networkx:

# First pip install pydot
# Then:
import streamlit as st
import networkx as nx

K5 = nx.complete_graph(5)
dot = nx.nx_pydot.to_pydot(K5)
st.graphviz_chart(dot.to_string())

If these don’t cut it for you, let me know!

Also, since I’m not familiar with Folium and Pyvis it would be great to see some code samples for things you’d like to do with those libraries. This way we can use those samples when thinking about how to implement support for those libraries in Streamlit.

HI Guys,

I’m really glad that someone has already asked this question, because I’m just looking for it.
It would simply be outstanding and breathtaking if we could do the following in streamlit:

st.network(nodes,edges)

Nodes and edges could be pre-definded similiar to vis.js (just in python):

nodes = st.graph.nodes([
{id: 1, label: ‘Node 1’},
{id: 2, label: ‘Node 2’},
{id: 3, label: ‘Node 3’},
{id: 4, label: ‘Node 4’},
{id: 5, label: ‘Node 5’}
])

edges = st.graph.edges([
{from: 1, to: 3},
{from: 1, to: 2},
{from: 2, to: 4},
{from: 2, to: 5},
{from: 3, to: 3}
])

If you could add additional parameters, that would be the ultimate, e.g. pictures in the node.

Thiago,

Adding support for Pyvis ( which uses vis.js under the covers ) would be great!
You can find a few samples here, these examples are too simple to repeat here.

Pyvis: https://pyvis.readthedocs.io/en/latest/tutorial.html

Thanks!

5 Likes

Hi Fellas,

I am working currently on a project trying to visualize a giant graph with streamlit.
The outcome is following:

Even though there is the enlarge button, the picture is really screwed up.
Therefore, I fully support the suggestion of @Vijay_Bhandari to get support
to vis.js or other librarys like D3.js to visualize graphs in an awesome way.
E.g. https://observablehq.com/@d3/force-directed-graph.
Do you guys @streamlit think this is possible?

Best regards
Chris