python seaborn boxplot_Seaborn boxplot box从Python列表中分配自定义边缘颜色

我想改变Seaborn boxplot中的框的外观。我希望所有的框都是透明的,并且要从列表中指定框边框。这里是我一起工作的代码:Seaborn boxplot box从Python列表中分配自定义边缘颜色

import numpy as np

import pandas as pd

import seaborn as sns

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

df = pd.DataFrame(np.random.rand(10,4),columns=list('ABCD'))

df['E'] = [1,2,3,1,1,4,3,2,3,1]

sns.boxplot(x=df['E'],y=df['C'])

# Plotting the legend outside the plot (above)

box = ax.get_position()

ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9])

handles, labels = ax.get_legend_handles_labels()

leg = plt.legend(handles[0:2], labels[0:2],

loc='upper center', bbox_to_anchor=(0.5, 1.10), ncol=2)

plt.show()

这post显示了如何改变一个单框的颜色和箱体edgecolor。但是,我想根据这样的列表分配框边框颜色,如box_line_col = ['r','g',b','purple']。上面的代码会在图中生成4个框 - 我想从第一个(最左边的)框开始并继续到最后一个(最右边的)框,分配自定义框边缘颜色。

是否可以从列表中指定盒子边缘颜色,同时保持盒子本身透明(facecolor = white)?

2016-05-13

W R

+1

[This](http://stackoverflow.com/questions/36874697/how-to-edit-properties-of-whiskers-fliers-caps-etc-in-seaborn-boxplot/36893152#36893152)回答我的问题类似的问题可以帮助你。 –

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值