olyabr
August 29, 2022, 9:34pm
1
Hello, is it possible to draw a line on a scatter plot in a dash plotly app and then return the coordinates of that line through the callback?
I was able to draw a line, but could not figure out how to access its properties, such as position on the plot.
Thanks,
Olga
AIMPED
August 30, 2022, 6:44am
2
Hi @olyabr ,
yes, it’s possible to do that. Here is an example:
from dash import Dash, dcc, html, Input, Output, State, callback_context
import dash_bootstrap_components as dbc
from scipy.ndimage import rotate
import plotly.express as px
from PIL import Image
import urllib.request
import numpy as np
import math
# get an example image from url
urllib.request.urlretrieve(
'https://raw.githubusercontent.com/michaelbabyn/plot_data/master/bridge.jpg',
'bridge.jpg'
)
# open image and create plotly figure, locally stored images can be used this way too
img = Image.open('bridge.jpg')
img_arr = np.array(img)
fig = px.imshow(img=img)
This file has been truncated. show original
1 Like
olyabr
August 30, 2022, 4:39pm
3
This is exactly what I needed to figure out! So greateful for your help!