当使用matplotlib绘制点图时,我希望偏移重叠的数据点以使它们都可见。例如,如果我有
CategoryA: 0,0,3,0,5
CategoryB: 5,10,5,5,10
我希望每个CategoryA
“0”数据点并排设置,而不是放在彼此的正上方,同时仍然与CategoryB
保持不同。
在R(ggplot2
)中,有一个"jitter"
选项可以做到这一点。matplotlib中是否有类似的选项,或者是否有其他方法会导致类似的结果?
编辑:澄清一下,the ^{
编辑:添加Seaborn的Swarmplot,在0.7版中引入,是我想要的一个很好的实现。
通过@user2467675扩展答案,我是这样做的:
变量
stdev
确保抖动足以在不同的尺度上看到,但它假定轴的限制为0和最大值。然后可以调用
jitter
,而不是scatter
。Seaborn通过^{} 提供直方图样的分类点图,通过^{} 提供抖动的分类点图:
我使用numpy.random将数据沿X轴“散布/蜂群”到每个类别的固定点上,然后基本上对每个类别执行pyplot.scatter():
相关问题 更多 >
编程相关推荐