44
55
66def degradation_summary_plots (yoy_rd , yoy_ci , yoy_info , normalized_yield ,
7- hist_xmin = None , hist_xmax = None ,
7+ hist_xmin = None , hist_xmax = None , bins = None ,
88 scatter_ymin = None , scatter_ymax = None ,
99 plot_color = None , summary_title = None ,
1010 scatter_alpha = 0.5 ):
@@ -33,6 +33,9 @@ def degradation_summary_plots(yoy_rd, yoy_ci, yoy_info, normalized_yield,
3333 lower limit of x-axis for the histogram
3434 hist_xmax : float, optional
3535 upper limit of x-axis for the histogram
36+ bins : int, optional
37+ Number of bins in the histogram distribution. If omitted,
38+ ``len(yoy_values) // 40`` will be used
3639 scatter_ymin : float, optional
3740 lower limit of y-axis for the scatter plot
3841 scatter_ymax : float, optional
@@ -57,6 +60,11 @@ def degradation_summary_plots(yoy_rd, yoy_ci, yoy_info, normalized_yield,
5760
5861 yoy_values = yoy_info ['YoY_values' ]
5962
63+ if bins is None :
64+ bins = len (yoy_values ) // 40
65+
66+ bins = int (min (bins , len (yoy_values )))
67+
6068 # Calculate the degradation line
6169 start = normalized_yield .index [0 ]
6270 end = normalized_yield .index [- 1 ]
@@ -67,8 +75,7 @@ def degradation_summary_plots(yoy_rd, yoy_ci, yoy_info, normalized_yield,
6775 y = [1 , 1 + (yoy_rd * years ) / 100.0 ]
6876
6977 fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (10 , 3 ))
70- ax2 .hist (yoy_values , label = 'YOY' , bins = len (
71- yoy_values ) // 40 , color = plot_color )
78+ ax2 .hist (yoy_values , label = 'YOY' , bins = bins , color = plot_color )
7279 ax2 .axvline (x = yoy_rd , color = 'black' , linestyle = 'dashed' , linewidth = 3 )
7380
7481 ax2 .set_xlim (hist_xmin , hist_xmax )
0 commit comments