Hey everyone!
First of all, I’d like to congratulate this community that is really surprising me since my first contact with streamlit.
Now, to the random subject: Has anyone considered using mpld3 in their streamlit project? What is the best approach? I’ve noticed that using mpld3.fig_to_html() may not be a good idea because it has a pretty big amount of js code…
Does anyone have a head start on this?
Hi @RicardoSQueen,
using the mpld3.fig_to_html()
method might be a good solution!
Of the top of my head, you could take a look at how the streamlit-folium component achieved this as it using static html/jc produced by Folium, and make your own component for mpld3.
This is roughly how it would look:
import streamlit.components.v1 as components
import matplotlib.pyplot as plt, mpld3
def mpld3_static(fig: plt.Figure, height=500, width=700, **mpld3_kwargs):
return component.html(fig.fig_to_html(**mpld3_kwargs), height=height, width=width)