Boxplot: colors by x value and hues differentiated by pattern

岁酱吖の 提交于 2019-11-28 09:34:13

问题


Say I have a boxplot like the one shown below:

I would like to achieve a different coloring:

  • Fri, Sat and Sun would be colored blue; Thur would be colored red

  • I would like to differentiate hues with a pattern in the box (stripped or something)

I can't find a way to do this manipulation using seaborn palette.

I know I can mess with the boxes of a boxplot in matplotlib directly but seaborn gives me the axes back. How can I get the boxes in this case?


回答1:


The boxes end up in the artists list on the returned axes, so you just need to manipulate the attributes on those objects:

ax = sns.boxplot(data=x)
box = ax.artists[0]
box. set_facecolor("white")

etc.



来源:https://stackoverflow.com/questions/31206474/boxplot-colors-by-x-value-and-hues-differentiated-by-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!