Hello!
New data scientist here!
I am triyng to create a stacked bar chart with certain extra info in the hovering text. However customdata does not allows introdcuing np.dstack data on it, and I can not get all my data with just a one dimmensional array.
my code:
yreadsPFRel = np.around(100*(readsPFTot/readsTot), 2)
dataPF = np.dstack((readsPFTot, yreadsPFRel))
fig = go.Figure()
fig.add_trace(go.Bar(x=x1,
y=yreadsAbs,
customdata=readsRel,
marker=dict(color='rgba(0,153,76,1)'),
name='Reads Assigned to an Index',
hovertemplate =
'<b>%{x}</b><br>'+
'<b>PF Reads assigned to Index</b>: %{y:.3str}<br>'+
'<b>Percentage over PF reads: </b> %{customdata} %')
)
fig.add_trace(go.Bar(x=x1,
y=yreadsPFTot,
customdata=dataPF,
marker=dict(color='rgba(0,153,76,0.5)'),
name='Total PF Reads',
hovertemplate =
'<b>%{x}</b><br>'+
'<b>PF reads</b>: %{customdata[0]:.3str}<br>'+
'<b>Percentage over Total Reads:</b> %{customdata[1]:.3str} %'
)
)
fig.add_trace(go.Bar(x=x1,
y=yreadsTot,
customdata=readsTot,
marker=dict(color='rgba(0,153,76,0.25)'),
name='Total Clusters',
hovertemplate=
'<b>%{x}</b><br>'+
'<b>Total Reads</b>: %{customdata:.3str}'
)
)
fig.update_layout(barmode='relative', title_text='Reads assigned to an Index')
fig.show()
the Result i am getting is