我已经在我的数据上运行了sklearn - 主成分分析,并使用3个主成分(PC1、PC2、PC3)进行了处理。数据看起来像这样(它是一个pandas DataFrame):
以下是绘制主成分的代码:
我的问题是,如何将标签(例如“GER,medium”)添加到点上?希望有人能够帮助我 :)
![enter image description here](https://istack.dev59.com/tnwkg.webp)
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
%matplotlib
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_title('3D Scatter Plot')
ax.set_xlabel('PC1')
ax.set_ylabel('PC2')
ax.set_zlabel('PC3')
ax.view_init(elev=12, azim=40) # elevation and angle
ax.dist=10 # distance
ax.scatter(
data_df_3dx['PC1'], data_df_3dx['PC2'], data_df_3dx['PC3'], # data
#color='purple', # marker colour
#marker='o', # marker shape
s=60 # marker size
)
plt.show()
我的问题是,如何将标签(例如“GER,medium”)添加到点上?希望有人能够帮助我 :)