@@ -554,21 +554,18 @@ def plot_pca(self, plot_filename=None, PCs=[1, 2], plot_title='', image_format=N
554554 lgd = None
555555
556556 # Scree plot
557- ind = np .arange (n_bars ) # the x locations for the groups
558- width = 0.35 # the width of the bars
559-
560- ax2 .bar (width + ind , eigenvalues [:n_bars ], width * 2 )
557+ ind = np .arange (n_bars ) + 1 # the x locations for the groups
558+
559+ ax2 .plot (ind , pvar , "bo-" )
561560 ax2 .set_xlabel ('Principal Component' )
562561 ax2 .set_title ('Scree plot' )
563- ax2 .set_xticks (ind + width * 2 )
564- ax2 .set_xticklabels (ind + 1 )
565-
566- ax3 = ax2 .twinx ()
567- ax3 .axhline (y = 1 , color = "black" , linestyle = "dotted" )
568- ax3 .plot (width * 2 + ind , pvar .cumsum ()[:n ], "r-" )
569- ax3 .plot (width * 2 + ind , pvar .cumsum ()[:n ], "wo" , markeredgecolor = "black" )
570- ax3 .set_ylim ([0 , 1.05 ])
571- ax3 .set_ylabel ('Cumulative variability' )
562+ ax2 .set_xticks (ind )
563+ ax2 .plot (ind , pvar .cumsum ()[:n ], "ro-" )
564+ ax2 .set_ylabel ('Variability' )
565+
566+ ax2 .axhline (y = 1 , color = "black" , linestyle = "dotted" )
567+
568+ ax2 .legend (['individual' , 'acumulative' ], loc = "center right" , labelcolor = ["blue" , "red" ], ncols = 1 )
572569
573570 if lgd is not None :
574571 plt .savefig (plot_filename , format = image_format , bbox_extra_artists = (lgd ,))
0 commit comments