Hey everyone - I was just wondering whether there was any way to grab hover data or click data from a px.imshow graph to use in a callback? Any links or help that you could provide would be very appreciated, thanks!
Wondering about the same question for quite a while…
AIMPED
January 21, 2023, 2:53pm
3
Hi @schwabts Welcome to the forums.
Here are two example apps where I do exactly this.
Click:
from dash import Dash, Input, Output, dcc, html
from dash.exceptions import PreventUpdate
import dash_bootstrap_components as dbc
import plotly.express as px
from PIL import Image
import urllib.request
# 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')
fig = px.imshow(img=img)
# update figure layout, actually not necessary for the functionality
fig.update_layout(
{
This file has been truncated. show original
Hover:
from dash import Dash, Input, Output, dcc, html
from dash.exceptions import PreventUpdate
import dash_bootstrap_components as dbc
import plotly.express as px
from PIL import Image
import urllib.request
import json
# 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')
fig = px.imshow(img=img)
# update figure layout, actually not necessary for the functionality
fig.update_layout(
This file has been truncated. show original
@dash-beginner