I am trying to annotate words on a scatterplot.
X is the result NLP preprocessing (dataframe of integers) and words is a list of words with same lenght as X and related to it.
print(X)
pca = PCA(n_components=3)
result = pca.fit_transform(X)
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(15,15))
ax = plt.axes(projection='3d')
ax.scatter3D(result[:,0], result[:,1], result[:, 2], cmap='Greens')
for i, txt in enumerate(words):
ax.annotate(txt, (result[:,0][i],result[:,1][i]))
Nonetheless, as shown in the picture, text description of words does not work properly, leaving a few instances without annotation.
How can I add the corresponding word to each datapoint in the 3D plot?