我有两个布尔变量,我试着用组创建一个箱线图。每个组应该代表一个变量,它应该包含两个框线图,一个代表真,一个代表假。相反,我得到两组,一组代表真,一组代表假,每组两组对应于每个变量的方框图,如附图所示:
我知道群是从xaxis派生的。但是我怎么能把变量名想象成组呢?我用于输出的代码:
trace3= Box(
y=raw_matrix.TPS,
x=raw_matrix.noClassGc,
name='noClassGc',
marker=Marker(
color='#3F5D7D'
))
trace4= Box(
y=raw_matrix.TPS,
x=raw_matrix.aggresiveOpts,
name='aggresiveOpts',
marker=Marker(
color='#0099FF'
))
data = Data([trace3, trace4])
layout = Layout(
yaxis=YAxis(
title='confidence',
zeroline=False),
boxmode='group',
boxgroupgap=0.5
)
fig = Figure(data=data, layout=layout)
plot_url = ploteczki.plot(fig, filename='Performance by categoricals parameters')
您需要重新排列数据数组,以便两条}的
Box
记录道具有'noClassGc'
和{'x'
坐标。在这个IPython notebook向您展示了如何这样做。在
或者,要用布尔盒图表示每个组,可以将每个记录道分配到不同的x轴。下面是一个例子:
这是the link to the plot
要了解更多信息,您可以签出Plotly Python reference
相关问题 更多 >
编程相关推荐