 What is probe number and segmentation mean in copy number variation(CNV) data
 Genetics and blue eyes
 I discovered a new organism… now what?
 Why Elizabeth was wet and alone?
 Can xray backprojection be converted to hardfield magnetic induction tomography?
 How to apply statistical algorithms to 'regulate' variation of a curve?
 Python Quad Weight Function for Square Root Singularity Integral
 How can I find positive integers a and p satisfying a^{p1}=1(mod p^2)?
 Why is the “se” needed in “la niña se baja del coche”?
 Perchas y Percheros?
 “Pull a Trump” in Spanish
 Error  Electrum wallet RPC method not supported
 Encrypted message with nLockTime
 Difference between staking and mining?
 Why is Ruth's child in the line of Boaz and not Mahlon?
 What was John Wesley's view of the Lord's Supper?
 Existetil un équivalent français de « crowdsourcing » ?
 “Some of them” in French
 Spectral leakage in frequency shift
 How to simulate audio PWM distortions in Matlab
How to annotate labels in a 3D matplotlib scatter plot?
I have made a 3x3 PCA matrix with sklearn.decomposition PCA and plotted it to a matplotlib 3D scatter plot.
How can I annotate labels near the points/marker? Here is my code:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
%matplotlib notebook
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.scatter(
existing_df_3dx['PC0'], existing_df_3dx['PC1'], existing_df_3dx['PC2'], # data
s=60 # marker size
)
plt.show()
Also, if you know of a better way to plot a 3D PCA, please post your code
Edit:
A solution provided from Stack Overflow:
for i in range(len(data_df_3dx)):
x, y, z = data_df_3dx.iloc[i]['PC1'], data_df_3dx.iloc[i]['PC2'], data_df_3dx.iloc[i]['PC3']
ax.scatter(x, y, z)
#now that you have the coordinates you can apply whatever text you need. I'm
#assuming you want the index, but you could also pass a column name if needed
ax.text(x, y, z, '{0}'.format(d

In the following posts [1], [2] the plotting of 3D arrows in matplotlib is discussed.
Similarly Annotation3D class (inherited from Annotation) can be created:
from mpl_toolkits.mplot3d.proj3d import proj_transform
from matplotlib.text import Annotation
class Annotation3D(Annotation):
'''Annotate the point xyz with text s'''
def __init__(self, s, xyz, *args, **kwargs):
Annotation.__init__(self,s, xy=(0,0), *args, **kwargs)
self._verts3d = xyz
def draw(self, renderer):
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.xy=(xs,ys)
Annotation.draw(self, renderer)
Further, we can define the annotate3D() function:
def annotate3D(ax, s, *args, **kwargs):
'''add anotation text s to to Axes3d ax'''
tag = Annotation3D(s, *args, **kwargs)
ax.add_artist(tag)
Using this function annotation tags can be added to Axes3d as in example bellow:
3D graph example
impor
20170321 00:31:16