大熊猫groupby boxplot红色对角线

时间:2016-06-15 10:49:49

标签: python pandas matplotlib boxplot

我正在用

绘制一个箱形图
    $params = [
        'index' => 'app',
        'type' => 'ad',
        'body' => [
            "from" => 0,
            "size" => 12,
            'query' => [
                "bool" => [
                    'should' => [
                        "constant_score" => [
                            "filter" => [
                                "and" => [
                                    ["missing" => [ "field" => "publishEnd" ]],
                                    ["term" => ['booked' => 0]],
                                ],
                            ],
                        ],
                        'filter' => [
                            ["term" => ['brand' => 'renault']],
                        ],
                    ],
                ],
            ],
        ],
    ];

情节很好,但有一条红色虚线对角线。这条线是什么?我该如何删除它?

获得的数字:

enter image description here

编辑: 这是一个可重复的例子:

>>> score.head()
       Score  Wafer_Slot
0 -10.710504          14
1   1.444185          23
2  -5.727797          14
3   8.029544          21
4  -1.569401          24

gscore = score.groupby('Wafer_Slot')
xticks = []
for i in range(25):
    xticks.append(str(i+1))
    xticks.append(' ')

gscore.boxplot(subplots=False)
ax = plt.gca()
ax.set_xticklabels(xticks)
plt.ylabel('Anomaly Score', size=20)
plt.xlabel('Wafer Slot', size=20)
plt.show()

1 个答案:

答案 0 :(得分:0)

我解决了。使用不同的变量作为分组索引就足够了:

score['Score'] = svm_score
ws = desc.Wafer_Slot[test_index].tolist()

gscore = score.groupby(ws)
xticks = []
for i in range(25):
    xticks.append(str(i+1))
    #xticks.append(' ')

gscore.boxplot(subplots=False)
ax = plt.gca()
ax.set_xticklabels(xticks)
plt.ylabel('Anomaly Score', size=20)
plt.xlabel('Wafer Slot', size=20)
#plt.savefig(plot_path + 'ocsvm_box_plot_by_wafer_slot.pdf')

plt.show()