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.

1 Like

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.

1 Like

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!

6 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

2 Likes

Hey @chris_klose :wave: ,

This should be possible with our new components architecture that will be launching soon. Pyvis & Folium would both make great components. Any interest in creating a component for one of these? We’d love to include you in the current closed beta if so. Here is a bit more info if interested.

2 Likes

Hi People,

Just wanted to provide another vote in favour of pyvis support.

A tool that could allow you to embed interactable graph visualizations would be the difference for me using streamlit in a couple of different projects which is needed if I want to sell this to other people in my organisation.

Thanks for all the great work,
Joseph

2 Likes

looking forward to this component that supports networkX. +1

1 Like

There are some progress on the interactive graph part :slight_smile: check out the following components:

Cheers,
Fanilo

3 Likes