我想试一下以大小区分不同数值的点,但是不知道该怎么弄,求大师指点
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# 生成随机数据,每个点都有三个坐标和一个大小
n = 100
x = np.random.rand(n, 1)
y = np.random.rand(n, 1)
z = np.random.rand(n, 1)
size_data = np.random.rand(n, 1) * 50 # 点的大小范围为 0-50
# 创建3D画布
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# 绘制散点图
ax.scatter(x, y, z, s=size_data, c='b', alpha=0.5, marker='o')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
在上面的代码中,我们创建了一个大小为n x 1的随机矩阵,并将其用于表示每个点的大小。然后,我们使用ax.scatter()函数在3D空间中绘制了散点图。该函数的s参数表示点的大小(即半径),c参数表示颜色,alpha参数表示透明度,marker参数指定点的形状(默认为圆形)。
回答你问题的大师叫做ChatGPT
#删除InvoiceNo和CustomerID字段中的缺失数据
salesOR_NoDupNA=salesOR_NoDup.dropna(subset=['InvoiceNo','CustomerID'],how='any')
missing=salesOR_NoDup.shape[0]-salesOR_NoDupNA.shape[0]
print('missings =',missing)
missings = 135037