Is there any solution to set individual legends’ colour manually ?
I have a chart as attached and I need to manually set the legend colours to be matched to another charts with same legends.
This is generated by using:
trace=[]
for colname, col in statusCountSorted[1:-1].iteritems():
trace.append(go.Bar(x=statusCountSorted.index, y=statusCountSorted[colname][0:-1],opacity=0.6,name=colname))
layout = go.Layout(
autosize=False,
width=800,
height=400,
barmode=‘stack’,
title = 'Top ‘+str(topCommonCount)+’ common issues from ‘+horizonStartDate+’ to ’ + endDate,
margin=go.Margin(
l=50,
r=50,
b=150,
t=50,
pad=0
))
trace=[]
for colname, col in statusCountSorted[1:-1].iteritems():
trace.append(go.Bar(
x=statusCountSorted.index,
y=statusCountSorted[colname][0:-1],
opacity=0.6,
name='<span style="{}">{}</span>'.format(color, colname)
))
Hi @etienne, thanks for getting back to me.
I tried your recommendation by defining color as follow:
color = [’#4682B4’, ‘#32CD32’, ‘#FF8000’,’#FF0000’]
trace=[]
for colname, col in statusCountSorted[1:-1].iteritems():
trace.append(go.Bar(x=statusCountSorted.index, y=statusCountSorted[colname][0:-1],opacity=0.6,
name=’{}’.format(color, colname)))
but it had no impact on the colors and they stayed same.
What do you think is missing ?
If anyone interested this is now resolved by:
1- setting up a function for colour selection
2- setting the colour through:
marker=dict(
color=colorSelector(colname),
)
and adding it in the go.Bar()
function sample:
def colorSelector( colname ):
if colname == “New Issue”:
return '#FF0000’
elif colname == “Closed Remotely”:
return ‘#4682B4’