密谋箱图:groupby选项? [英] Plotly boxplot: groupby option?

查看:128
本文介绍了密谋箱图:groupby选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个布尔变量,我尝试创建带有组的箱线图.每个组应代表一个变量,并且应包含两个箱形图,一个用于TRUE,另一个用于FALSE.相反,我得到了两个组,一个代表TRUE,一个代表FALSE,对于每组,两个箱形图对应于每个变量,如下图所示:

I have two boolean variables and I try to create a boxplot with groups. Each group should represent one of the variables and it should contain two boxplots, one for TRUE and one for FALSE. Instead I am getting two groups, one representing TRUE and one representing FALSE and for each group two boxplots corresponding to each variable as in the attached graph:

我知道群组是从xaxis派生的.但是,如何使他们以变量名为组呢?我用于输出的代码:

I understand that groups are derived from the xaxis. But how can I make plotly think that the variable names are the groups? The code I used for the output :

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')

推荐答案

或者,要通过布尔框图表示每个组,可以将每个迹线分配给不同的x轴.这是一个示例:

Alternatively, to represent each group by its boolean boxplots, you can assign each trace to different x-axes. Here is an example:

trace0 = Box(
    y=raw_matrix_TPS,
    x=raw_matrix_noClassGc,
    name='noClassGc',
    marker=Marker(
        color='#3F5D7D'
    )
)
trace1 = Box(
    y=raw_matrix_TPS,
    x=raw_matrix_aggresiveOpts,
    name='aggresiveOpts',
    xaxis='x2',
    marker=Marker(
        color='#0099FF'
    )
)
data = Data([trace0, trace1])
layout = Layout(
    xaxis = XAxis(
        domain=[0, 0.55],
    ),
    xaxis2 = XAxis(
         domain=[0.55, 1],
    ),
    yaxis = YAxis(
         title='confidence',
         zeroline=False
    ),
    boxmode='group',
    boxgroupgap=0.5
)
fig = Figure(data=data, layout=layout)
plot_url = py.plot(fig, filename='Performance by categoricals parameters')

这是指向该图的链接

要了解更多信息,可以签出 Plotly Python参考

To learn more, you can checkout Plotly Python reference

这篇关于密谋箱图:groupby选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆