我使用下面的代码生成具有多个跟踪的图表。但是,我知道为每个轨迹应用不同颜色的唯一方法是使用 randon 函数,该函数为颜色使用数字 RGB。
但随机颜色不利于演示。
我如何为下面的代码使用托盘颜色并且不会获得更多随机颜色?
groups53 = dfagingmedioporarea.groupby(by='Area')
data53 = []
colors53=get_colors(50)
for group53, dataframe53 in groups53:
dataframe53 = dataframe53.sort_values(by=['Aging_days'], ascending=False)
trace53 = go.Bar(x=dataframe53.Area.tolist(),
y=dataframe53.Aging_days.tolist(),
marker = dict(color=colors53[len(data53)]),
name=group53,
text=dataframe53.Aging_days.tolist(),
textposition='auto',
)
data53.append(trace53)
layout53 = go.Layout(xaxis={'title': 'Area', 'categoryorder': 'total descending', 'showgrid': False},
yaxis={'title': 'Dias', 'showgrid': False},
margin={'l': 40, 'b': 40, 't': 50, 'r': 50},
hovermode='closest',
template='plotly_white',
title={
'text': "Aging Médio (Dias)",
'y':.9,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'})
figure53 = go.Figure(data=data53, layout=layout53)
Run Code Online (Sandbox Code Playgroud)