我正在尝试根据绘图文档示例构建多个分割小提琴图。我不知道为什么小提琴被水平地弄脏了。我包括了 violinmode='overlay',这是另一个人曾经建议的,但它没有什么区别。
下面是我正在使用的代码
lengthlm = go.Figure()
lengthlm.add_trace(go.Violin(x=lastmonth['agegroup'][lastmonth['type']=='Canine'],
y=lastmonth['lengthyr'][lastmonth['type']=='Canine'],
legendgroup='Canine',
scalegroup='Canine',
name='Canine',
side='negative',
line_color=color_list[1]))
lengthlm.add_trace(go.Violin(x=lastmonth['agegroup'][lastmonth['type']=='Feline'],
y=lastmonth['lengthyr'][lastmonth['type']=='Feline'],
legendgroup='Feline',
scalegroup='Feline',
name='Feline',
side='positive',
line_color=color_list[0]))
lengthlm.update_xaxes(type='category', categoryorder='array', categoryarray=['< 1 Yr','< 5 Yrs',
'< 10 Yrs','< 15 Yrs','15+ Yrs'])
lengthlm.update_traces(meanline_visible=True)
lengthlm.update_layout(violinmode='overlay',
violingap=0,
template=dash_template,
height=400,
width=750,
margin=dict(l=70))
lengthlm.show()