-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Unfortunately this is not possible via plotly currently. Plotly's legend symbols are 1-1 with their marker counterparts such that the user can essentially only change the legend via the markers characteristics. I.e. Making the bar graph purple will make the legend symbol purple, but you can't directly change the legend to purple without changing the bar graph to be purple. source
When creating a bar graph like so:
import plotly.express as px
df = px.data.tips()
fig = px.histogram(df, x="sex", y="total_bill",
color='smoker', barmode='group',
height=400)
fig.show()
It creates a legend that reflects the graph style.

There's no property that allows you to change or customize the icon used in the legend.
The request is to create a property in plotly express that allows you to choose the legend marker. Default could be the current case, which is to match the graph. Other options could be line, square or circle.
This FR came from an enterprise client and in my research I found it was echoed by the community as well
https://stackoverflow.com/questions/66814448/plotly-how-to-change-legend-item-shape-from-line-to-box-or-circle-in-a-line-cha
https://stackoverflow.com/questions/66456467/custom-markers-in-plotly-dash-legend