boxplot - 选择色调后,Seaborn boxplots 会更改(缩小)框的宽度,我该如何补救?

标签 boxplot seaborn

我正在使用 seaborn 创建箱线图。当我指定一列对框进行分组/着色时,框的宽度变得非常窄,以至于很难看到。我所做的唯一更改是为hue 指定一个参数,它指向传递的数据帧中的一列。我曾尝试使用 'width' 参数(如前所述 here ),它确实增加了箱线图的宽度,但也增加了它们分开的距离。

帮助:如何在指定色调参数时保持框的宽度?

我将在下面展示我的代码和结果:

我的数据框:

Out[3]: 
                   timestamp   room_number floor       floor_room  temperature
0  2016-01-19 09:00:00-05:00         11a06    11         11_11a06          23.0
1  2016-01-19 09:00:00-05:00    east-inner    11    11_east-inner          22.8
2  2016-01-19 09:00:00-05:00   east-window    11   11_east-window          22.9

使用具有奇数箱线图宽度的 seaborn,使用分组因子:
sns.boxplot(x=xunit, y=var, data=df, order=order, hue='floor')

enter image description here

使用具有合理箱线图宽度但没有分组因子的 seaborn:
sns.boxplot(x=xunit, y=var, data=df)

enter image description here

最佳答案

在 0.8 版(2017 年 7 月)中,dodge添加了参数

to boxplot, violinplot, and barplot to allow use of hue without changing the position or width of the plot elements, as when the hue varible is not nested within the main categorical variable.



( release notes v0.8.0 )

您的代码如下所示:
sns.boxplot(x=xunit, y=var, data=df, order=order, hue='floor', dodge=False)

关于boxplot - 选择色调后,Seaborn boxplots 会更改(缩小)框的宽度,我该如何补救?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36092363/

相关文章:

r - 将图例符号从 geom_boxplot 符号更改为正方形

python - 带有第二个 y 轴的 Seaborn 图

r - 带有 ggplot2 的箱线图 : Trying to lay geom_jitter over code for plot, 奇怪的离群点

python - 如何在 matplotlib boxplot 中更改 mustache 帽的长度

r - 在 R 中按均值(而不是中值)对箱线图进行排序

python - Seaborn 中条形图和误差线的美观

python - 如何插入统计注释(星号或 p 值)

python - 如何使用facet创建条形图并使用seaborn添加标签

python - 使用seaborn.facetgrid,如何指定映射散点图的颜色以反射(reflect)数据框中列的值?

python - 在python matplotlib中调整boxplot中框的宽度