'Is there a way to add discrete labels to plotly imshow images

I am using plotly to show an image using fig=px.imshow(img)

I would like it to have a discret legend similar to the ones in the pie chart or the bar chart: fig2 = px.pie(df, values=df[0],names=df.index,color =df.index, color_discrete_map= h.colormap)

imshow() does not have the argument color_discret_map but maybe there could be a work-around ?

I know it is possible with matplotlib but I need plotly to do it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source