pythonmatplotlibstreamlitmatplotlib-widget

Matplotlib interactive figures with streamlit


I am trying to display matplotlib interactive figures in Streamlit generated pages i.e. to display the pan/zoom and mouse-location tools.

I know there are other ways to make figures interactive that are commonly used with streamlit, but I need to stick to matplotlib because they provide widgets that I use (rectangle selector for example).

Is such a thing possible?


Solution

  • There is no way at the moment to create interactive matplotlib figures inside Streamlit.

    Source:

    Also, an issue was opened more than 2 years ago on the Streamlit's GitHub repository, asking for the same thing: https://github.com/streamlit/streamlit/issues/4213. It was closed and merged to another issue as a part of a feature on interactive components such as pandas dataframes and matplotlib figures. However, the issue they are referring to has been closed as completed, but the work seems to have been done only for interactive dataframes so far.


    My advice, the one I follow currently in my Streamlit development, is to use Plotly instead. See the st.plotly_chart documentation.