I am having two graphs, with one of them hovertext is part of the click data, for the other one not.
I do not understand why. Hovertext and name also are correctly displayed when hovering over the points of the graph, but they are not present in the click data.
Anybody has any ideas what the differences between the two graphs are, and how I can get either hovertext, text, or name in the click data of the second graph?
I only need one of those, and the only one that works (custom data) does funnily enough not even work for the first graph.
for i in classes:
#subsetting the data by the class
dat_class=dat.loc[dat[classifier_column]==i]
#getting only the cells from that class
cells=list(dat_class[identifier_column].unique())
print('...of class ', i, '...')
if testmode==True:
cells=cells[50:100]
#append the current classes name to the titles of the plot
#looping through the cells
for c in cells:
#appending x, y data based on current cell to the list of traces
fig.append_trace(trace=go.Scatter(
#getting x values
x=dat_class.loc[dat_class[identifier_column]==c][X_column],
#getting y values
y=dat_class.loc[dat_class[identifier_column]==c][Y_column],
#getting unique ID
hovertext=dat_class.loc[dat_class[identifier_column]==c]['unique_time']),
row=int(rowlist[math.floor(r_i)]) , col=1)
#adding 1 to the row indicator, so that every class will be
#plottet in a new row
fig.update_yaxes(range=[min_y*1.05, max_y*1.05], row=int(rowlist[math.floor(r_i)]), col=1)
fig.update_xaxes(range=[min_x*1.05, max_x*1.05], row=int(rowlist[math.floor(r_i)]), col=1)
r_i+=1
fig.update_layout(margin={'l': 40, 'b': 5, 't': 30, 'r': 40},
height=row_n*375, width=750)
fig.update_layout({'clickmode':'event+select'})
ClickData output returns:
{
"points": [
{
"curveNumber": 76,
"pointNumber": 51,
"pointIndex": 51,
"x": 256.3593756574,
"y": -103.1261306744,
"hovertext": "WC3_S421_E1_T52"
}
]
}
for i in list(image_info[2]['alt_cells'].keys()):
fig.add_trace(go.Scatter(
hovertext='hovertext',
customdata=['customdata'],
name='name',
text=i,
x=[image_info[2]['alt_cells'][i][0]],
y=[abs((image_info[2]['alt_cells'][i][1]-y_C))],
mode='markers',
marker_opacity=0.5,
#marker_colour='rgba(0, 0, 255, .9)',
)
)
fig.update_layout(
images=[
go.layout.Image(source=img,
xref='x',
yref='y',
x=0,
y=y_C,
#using input image sizes as the
#axes legnths for the graph
sizex=x_C,
sizey=y_C,
sizing='stretch',
opacity=1,
layer='below')],
#defining height and width of the graph
height=750,
width=750*aspect_ratio)
fig.update_xaxes(visible=False, range=[0, x_C])
fig.update_yaxes(visible=False, range=[0, y_C])
fig.update_layout({'clickmode':'event+select'})
ClickData output returns:
{
"points": [
{
"curveNumber": 7,
"pointNumber": 0,
"pointIndex": 0,
"x": 149,
"y": 675,
"customdata": "customdata"
}
]
}