and comment/delete your text=df.apply...
You can comment textposition='auto' or not, depending on whether you want the text to be displayed only on hover or not.
Here is the image illustrating how the plot looks with the text displayed on bars, too, not only on hover:
Thanks @empet, that’s helpful but not quite there. What I’m trying to do is display basic info on the graph, and provide additional info only on hover.
I only want sepal length displayed as text on the graph, but on hover display all four. I.e I want the charts to look as they are in my code in the OP, but have the hovertext as your code.
Is that possible, or is the marker text always the same as the hover text (and I can only choose whether or not to show it)?
@QuinRiva if you want to display only the sepal length as annotation (the text displayed on your bars), then define the plot layout and insert within this dict the annotations, as follows:
layout=dict(width=650,
height=400,
autosize=False,
annotations=[dict(font= dict(color='rgb(100,100,100)'),
showarrow=False,
text= 'sepal length: '+'{:.2f}'.format(df.loc[k, 'sepal length (cm)']),
x= df.loc[k, 'sepal length (cm)']-1,#here I subtracted 1 from the sepal length to avoid displaying
#the text at the bar end
xref= 'x',
y= df.loc[k, 'target'],
yref= 'y') for k in range(len(df))]
)
Comment textposition=‘auto’ in trace1.
If you don’t want to display these annotations, just don’t include them within layout definition.