简体   繁体   English

如何在python中的散点图中平滑数据点?

[英]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.

相关问题 获取在python中不同散点图区域绘制的点数据 - To get data of points plotted in different area of scatter plots in python 单击 Plotly 散点图中的数据点时打开 URL [Python] - Open URL when clicking on data points in Plotly scatter plots [Python] 如何为 python 中的每个数据生成单独的散点图? - How to produce separate scatter plots for each data in python? 如何使用plotly python中的下拉按钮更新多个散点图的数据? - How to update data of multiple scatter plots with dropdown buttons in plotly python? 在matplotlib中,在散点图中的数据点周围绘制一个光滑的多边形 - draw a smooth polygon around data points in a scatter plot, in matplotlib plot如何通过Python 3中的真实数据点平滑曲线? - How to plot smooth curve through the true data points in Python 3? Plotly:如何手动设置 plotly express 散点图中点的颜色? - Plotly: How to manually set the color of points in plotly express scatter plots? 如何使用matplotlib根据散点图的类型为散点图上的各个点着色 - How to color individual points on scatter plots based on their type using matplotlib 如何创建一个使用python一一绘制散点图的视频? - How to create a video that plots the scatter plots one by one using python? 使用python为散点图中的数据点着色 - colouring data points in a scatter plot using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM