@@ -4019,7 +4019,7 @@ def create_candlestick(open, high, low, close,
4019
4019
@staticmethod
4020
4020
def create_distplot (hist_data , group_labels ,
4021
4021
bin_size = 1. , curve_type = 'kde' ,
4022
- colors = [], rug_text = [],
4022
+ colors = [], rug_text = [], histnorm = 'probability density' ,
4023
4023
show_hist = True , show_curve = True ,
4024
4024
show_rug = True ):
4025
4025
"""
@@ -4144,23 +4144,23 @@ def create_distplot(hist_data, group_labels,
4144
4144
bin_size = [bin_size ]* len (hist_data )
4145
4145
4146
4146
hist = _Distplot (
4147
- hist_data , group_labels , bin_size ,
4147
+ hist_data , histnorm , group_labels , bin_size ,
4148
4148
curve_type , colors , rug_text ,
4149
4149
show_hist , show_curve ).make_hist ()
4150
4150
4151
4151
if curve_type == 'normal' :
4152
4152
curve = _Distplot (
4153
- hist_data , group_labels , bin_size ,
4153
+ hist_data , histnorm , group_labels , bin_size ,
4154
4154
curve_type , colors , rug_text ,
4155
4155
show_hist , show_curve ).make_normal ()
4156
4156
else :
4157
4157
curve = _Distplot (
4158
- hist_data , group_labels , bin_size ,
4158
+ hist_data , histnorm , group_labels , bin_size ,
4159
4159
curve_type , colors , rug_text ,
4160
4160
show_hist , show_curve ).make_kde ()
4161
4161
4162
4162
rug = _Distplot (
4163
- hist_data , group_labels , bin_size ,
4163
+ hist_data , histnorm , group_labels , bin_size ,
4164
4164
curve_type , colors , rug_text ,
4165
4165
show_hist , show_curve ).make_rug ()
4166
4166
@@ -5036,10 +5036,11 @@ class _Distplot(FigureFactory):
5036
5036
"""
5037
5037
Refer to TraceFactory.create_distplot() for docstring
5038
5038
"""
5039
- def __init__ (self , hist_data , group_labels ,
5039
+ def __init__ (self , hist_data , histnorm , group_labels ,
5040
5040
bin_size , curve_type , colors ,
5041
5041
rug_text , show_hist , show_curve ):
5042
5042
self .hist_data = hist_data
5043
+ self .histnorm = histnorm
5043
5044
self .group_labels = group_labels
5044
5045
self .bin_size = bin_size
5045
5046
self .show_hist = show_hist
@@ -5081,7 +5082,7 @@ def make_hist(self):
5081
5082
x = self .hist_data [index ],
5082
5083
xaxis = 'x1' ,
5083
5084
yaxis = 'y1' ,
5084
- histnorm = 'probability density' ,
5085
+ histnorm = self . histnorm ,
5085
5086
name = self .group_labels [index ],
5086
5087
legendgroup = self .group_labels [index ],
5087
5088
marker = dict (color = self .colors [index ]),
@@ -5108,7 +5109,9 @@ def make_kde(self):
5108
5109
self .curve_y [index ] = (scipy .stats .gaussian_kde
5109
5110
(self .hist_data [index ])
5110
5111
(self .curve_x [index ]))
5111
- # self.curve_y[index] *= self.bin_size[index]
5112
+
5113
+ if self .histnorm == 'probability' :
5114
+ self .curve_y [index ] *= self .bin_size [index ]
5112
5115
5113
5116
for index in range (self .trace_number ):
5114
5117
curve [index ] = dict (type = 'scatter' ,
@@ -5143,7 +5146,9 @@ def make_normal(self):
5143
5146
/ 500 for x in range (500 )]
5144
5147
self .curve_y [index ] = scipy .stats .norm .pdf (
5145
5148
self .curve_x [index ], loc = mean [index ], scale = sd [index ])
5146
- # self.curve_y[index] *= self.bin_size[index]
5149
+
5150
+ if self .histnorm == 'probability' :
5151
+ self .curve_y [index ] *= self .bin_size [index ]
5147
5152
5148
5153
for index in range (self .trace_number ):
5149
5154
curve [index ] = dict (type = 'scatter' ,
@@ -5621,4 +5626,3 @@ def make_table_annotations(self):
5621
5626
font = dict (color = font_color ),
5622
5627
showarrow = False ))
5623
5628
return annotations
5624
-
0 commit comments