Matplotlib Draggable

I want to add matplotlib draggable into streamlit.
I saw an old post trying to implement it in 2021, back then it wasn’t possible.

example code that I would like to replicate in a streamlit app:

import PySide6
import matplotlib.pyplot as plt
%matplotlib qt

#sample data and plot
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
plt.plot(x, y)

for i in range(len(x)):
    ann = plt.annotate(f'({x[i]}, {y[i]})', xy=(x[i], y[i]), xytext=(x[i], y[i]+5), textcoords='data', arrowprops=dict(arrowstyle='->'))
    ann.draggable()
legend.set_draggable(True)

Figure12024-09-2614-15-25-ezgif.com-video-to-gif-converter

Any idea if this is possible now?
Would love to implement this in my app

If there is an easy way to do this in plotly, that would also be super useful - but i could not find a straight forward way

Depending on what you’re trying to do, plotly will let you draw shapes on a graph, like this:

import streamlit as st
import plotly.graph_objects as go

fig = go.Figure()

dragmode_options = [
    "drawclosedpath",
    "drawopenpath",
    "drawline",
    "drawrect",
    "drawcircle",
]

dragmode = st.selectbox("Select drag mode", dragmode_options)
fig.update_layout(
    dragmode=dragmode,
    # style of new shapes
    newshape=dict(line_color="yellow", fillcolor="turquoise", opacity=0.5),
)

st.plotly_chart(fig)

See it in-action here

I updated the post with my code to clarify what i mean.
I want annotations of points and to be able to move them like in the matplotlib graph above.

Gotcha. Sorry, I don’t know of a way to do that currently – that would be a cool component if someone wanted to build it.

Matplotlib charts by default in streamlit are just images, and so don’t allow any sort of interaction.