I have been trying all day to add max value annotation to a plotly plot. I figured out how to do it manually but I am more interested in a more automatic solution. I added my code in but omitted anything unrelated.
Is there a way to add a label to the max points of my plotly scatterplot?
P.S. Please be nice this is my first posting here.
The relevant part of the code:
import plotly.express as px
import pandas as pd
m = df['values'].max()
day_order = ['Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday']
fig = px.scatter(df,
x='day-of-week',
y ='values',
category_orders = {
'day-of-week': day_order})
fig.add_annotation(x='Sunday',
y=m,
text=m)



my_chart.add_annotation(x=df[df['values']==max(df['values'])]['day-of-week'].head(1),y=max(df['values']),text=max(df['values']))df. It will be great if you can have a look at How to Ask and then try to produce a minimal reproducible example.pandasit is better to usedf['values'].max()instead ofmax(df['values'])