I am hoping I can apply this draw_vector function onto an Altair scatter plot rather than matplotlib. I am having trouble with a workaround. Your expertise would be appreciated!
def draw_vector(v0, v1, ax=None):
ax = ax or plt.gca()
arrowprops=dict(arrowstyle='->',
linewidth=2,
shrinkA=0, shrinkB=0)
ax.annotate('', v1, v0, arrowprops=arrowprops)
# plot data
plt.scatter(X[:, 0], X[:, 1], alpha=0.2)
for length, vector in zip(pca.explained_variance_, pca.components_):
v = vector * 3 * np.sqrt(length)
draw_vector(pca.mean_, pca.mean_ v)
plt.axis('equal');
Here is what the above code produces for reference:
CodePudding user response:
I recognize that chart