File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -250,11 +250,16 @@ loadings = pca.components_.T * np.sqrt(pca.explained_variance_)
250
250
fig = px.scatter(components, x = 0 , y = 1 , color = df[' species' ])
251
251
252
252
for i, feature in enumerate (features):
253
- fig.add_shape(
254
- type = ' line' ,
255
- x0 = 0 , y0 = 0 ,
256
- x1 = loadings[i, 0 ],
257
- y1 = loadings[i, 1 ]
253
+ fig.add_annotation(
254
+ ax = 0 , ay = 0 ,
255
+ axref = " x" , ayref = " y" ,
256
+ x = loadings[i, 0 ],
257
+ y = loadings[i, 1 ],
258
+ showarrow = True ,
259
+ arrowsize = 2 ,
260
+ arrowhead = 2 ,
261
+ xanchor = " right" ,
262
+ yanchor = " top"
258
263
)
259
264
fig.add_annotation(
260
265
x = loadings[i, 0 ],
@@ -263,6 +268,7 @@ for i, feature in enumerate(features):
263
268
xanchor = " center" ,
264
269
yanchor = " bottom" ,
265
270
text = feature,
271
+ yshift = 5 ,
266
272
)
267
273
fig.show()
268
274
```
You can’t perform that action at this time.
0 commit comments