我有一个等级表,我希望所有的垃圾箱都在同一个宽度
我希望垃圾箱的范围为[0,56,60,65,70,80,85,90,95100] 当第一个箱子从0-56然后是56-60。。。同宽
sns.set_style('darkgrid')
newBins = [0,56,60,65,70,80,85,90,95,100]
sns.displot(data= scores , bins=newBins)
plt.xlabel('grade')
plt.xlim(0,100)
plt.xticks(newBins);
不是我要找的:
如何平衡垃圾箱的宽度
你需要欺骗一下。定义您自己的存储箱,并使用线性范围命名存储箱。以下是一个例子:
输出:
旧答案:
你为什么不让seaborn帮你挑选垃圾箱:
或者设置所需的垃圾箱数量:
它们将均匀分布
只需更改用作绑定的值列表:
将列表分配给
sns.distplot()
的bins
参数。这将指定垃圾箱的边缘。由于这些边缘的间距不均匀,因此箱子的宽度会有所不同我认为您可能希望使用条形图(
sbs.barplot()
),而不是直方图。您需要计算每个箱子中有多少个数据点,然后绘制条形图,而不知道每个条形图表示的值的范围。大概是这样的:它给出:
相关问题 更多 >
编程相关推荐