Plotly ordering the hover labels at each x axis point

1 week ago 3
ARTICLE AD BOX

I want that the hover labels to appear ordered by the y axis value at each x axis point.

import plotly_express as px fig = px.line( [ dict(price=2, year=2023, product='A'), dict(price=3, year=2024, product='A'), dict(price=3, year=2023, product='B'), dict(price=2, year=2024, product='B'), ], x = 'year', y = 'price', line_group = 'product', color = 'product' ) fig.update_layout( hovermode = 'x unified', hoverlabel = dict( namelength = -1 ) ) fig.show()

They are ordered the same as the legend items in all the x points:

enter image description here enter image description here

I want the hover labels to be ordered by price descending at each x point. I hope there is some key in the hoverlabel dict, but I can't find it.

Read Entire Article