[英]How to smooth data points in scatter plots in python?
I have a scatter plot where I am coloring each data point based on an array: 我有一个散点图,我根据数组着色每个数据点:
plt.scatter(xs,ys,c=av,cmap=plt.cm.hot,s=50,alpha=0.5)
In [96]: xs.shape
Out[96]: (5594,)
In [97]: ys.shape
Out[97]: (5594,)
In [98]: av.shape
Out[98]: (5594,)
and this is the result: 这就是结果:
Now, I want to keep the color but smooth the data points to get a smoothed scatter plot, something like this (from this post ) or this image: 现在,我想保持颜色,但要平滑数据点以获得平滑的散点图,如下所示(来自此帖子 )或此图像:
Comment: I figured that if I can add more points to my xs, ys, zs
I can make the scatter plot with more data points, hence, it will look more like a heatmap plot, which is what I want. 评论:我认为如果我可以为我的xs, ys, zs
添加更多的点xs, ys, zs
我可以使散点图具有更多的数据点,因此,它看起来更像是热图图,这就是我想要的。 Now, for every point in xs, ys, zs
, I want to add additional points with similar values around original points. 现在,对于xs, ys, zs
每个点,我想在原始点周围添加具有相似值的附加点。 Ideally, these additional points should form a normal distribution around actual original points in the xs, ys, zs
. 理想情况下,这些附加点应在xs, ys, zs
围绕实际原始点形成正态分布。 Is there a statistical tools to do this task? 有没有统计工具来完成这项任务? Eg How to change [1, 5, 10]
to [0.9,0.98,1,1.02,1.1, 4.9,4.98,5,5.02,5.1, 9.9,9.98,10,10.02,10.1]
? 例如,如何将[0.9,0.98,1,1.02,1.1, 4.9,4.98,5,5.02,5.1, 9.9,9.98,10,10.02,10.1]
[1, 5, 10]
改为[0.9,0.98,1,1.02,1.1, 4.9,4.98,5,5.02,5.1, 9.9,9.98,10,10.02,10.1]
?
OP : Is there a statistical tools to do this task? OP :有没有统计工具来完成这项任务? Eg How to change [1, 5, 10] to [0.9,0.98,1,1.02,1.1, 4.9,4.98,5,5.02,5.1, 9.9,9.98,10,10.02,10.1] ? 例如,如何将[1,5,10]改为[0.9,0.98,1,1.02,1.1,4.9,4.98,5,5.02,5.1,9.9,9.98,10,10.02,10.1]?
obs=[1, 5 ,10]
syntheticobs=np.random.normal(0,0.1,(6,3))+obs
synthethicobs
Out[]:array([[ 1.02166209, 5.00716569, 9.96726293],
[ 0.96727493, 4.94823697, 10.03424305],
[ 1.10756036, 5.12464335, 9.86776082],
[ 0.97866246, 5.12743117, 10.06647638],
[ 0.87842188, 5.00994338, 10.1114983 ],
[ 1.10728294, 4.82523615, 10.03642462]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.