python - 云间距

标签 python matplotlib

示例 1

enter image description here

示例 2

enter image description here

在这两张图片上,我们可以清楚地区分出两片不同的云。

这是生成这两个图像的代码部分:

fig = plt.figure(figsize = (8,8))
ax = fig.add_subplot(1, 1, 1, projection='3d') 

#ax.set_xlabel('PC 1', fontsize = 15)
#ax.set_ylabel('PC 2', fontsize = 15)
ax.set_xlim3d([-10, 10])
ax.set_ylim3d([-10, 10])
ax.set_zlim3d([-10, 10])
ax.set_title('2 Component PCA', fontsize = 20)

targets = [1, 0]
colors = ['r', 'g']
for target, color in zip(targets,colors):
    indicesToKeep = finalDf['Label_Capture_Spread'] == target
    ax.scatter(finalDf.loc[indicesToKeep, 'PC 1'],
               finalDf.loc[indicesToKeep, 'PC 2'],
               finalDf.loc[indicesToKeep, 'PC 3'],
               c = color,
               s = 20)
ax.legend(targets)
ax.grid()

在这两张图像上,两片云之间都没有空间。有没有办法将两朵云彼此分开?我们能否将点放在气泡中以清楚地区分每朵云?

最佳答案

我相信有帮助的是尝试从点中找出凸包,并与点一起绘制形状(或不与点一起绘制)。您可以在问题 Plotting a set of given points to form a closed curve in matplotlib 中找到 2d 解决方案的草图。 .

关于python - 云间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51366241/

相关文章:

python - 如何覆盖 modelform 类的 save() 方法并添加缺失信息?

python - 在 Python 中绘制正弦曲线的傅里叶变换

python - 绘制两个数组的最小值

python - 在 Matplotlib 绘图外绘制箭头

python - 插入图片作为图形的背景?

python - 如何绘制具有指数核的泊松过程

python - 什么是用垃圾收集语言进行计算几何(如 CGAL)的好库?

Python,将字段扩展/添加到元组

python - 不区分大小写的字典搜索?

python - 从 "alpha blending"获取一个新的十六进制颜色值 matplotlib 中的原始颜色