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_)
250250fig = px.scatter(components, x = 0 , y = 1 , color = df[' species' ])
251251
252252for 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"
258263 )
259264 fig.add_annotation(
260265 x = loadings[i, 0 ],
@@ -263,6 +268,7 @@ for i, feature in enumerate(features):
263268 xanchor = " center" ,
264269 yanchor = " bottom" ,
265270 text = feature,
271+ yshift = 5 ,
266272 )
267273fig.show()
268274```
You can’t perform that action at this time.
0 commit comments