-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Distplot fix #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Distplot fix #473
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c2c1f18
changed histnorm to prob-density and adjusted both types of curves
yankev ada8147
fixed tests to comply with change to histnorm (-> probability density)
yankev 1245b10
added line back at the end of the file
yankev b28b4a2
added histnorm parameter
yankev e4e53ef
added tests to cover both options of histnorm
yankev 342fa54
edited docstring
yankev 4570e59
changed default to probability density
yankev 141a789
changed default value in docstring
yankev bda2531
put histnorm values into variables
yankev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4019,7 +4019,7 @@ def create_candlestick(open, high, low, close, | |
@staticmethod | ||
def create_distplot(hist_data, group_labels, | ||
bin_size=1., curve_type='kde', | ||
colors=[], rug_text=[], | ||
colors=[], rug_text=[], histnorm='probability', | ||
show_hist=True, show_curve=True, | ||
show_rug=True): | ||
""" | ||
|
@@ -4144,23 +4144,23 @@ def create_distplot(hist_data, group_labels, | |
bin_size = [bin_size]*len(hist_data) | ||
|
||
hist = _Distplot( | ||
hist_data, group_labels, bin_size, | ||
hist_data, histnorm, group_labels, bin_size, | ||
curve_type, colors, rug_text, | ||
show_hist, show_curve).make_hist() | ||
|
||
if curve_type == 'normal': | ||
curve = _Distplot( | ||
hist_data, group_labels, bin_size, | ||
hist_data, histnorm, group_labels, bin_size, | ||
curve_type, colors, rug_text, | ||
show_hist, show_curve).make_normal() | ||
else: | ||
curve = _Distplot( | ||
hist_data, group_labels, bin_size, | ||
hist_data, histnorm, group_labels, bin_size, | ||
curve_type, colors, rug_text, | ||
show_hist, show_curve).make_kde() | ||
|
||
rug = _Distplot( | ||
hist_data, group_labels, bin_size, | ||
hist_data, histnorm, group_labels, bin_size, | ||
curve_type, colors, rug_text, | ||
show_hist, show_curve).make_rug() | ||
|
||
|
@@ -5036,10 +5036,11 @@ class _Distplot(FigureFactory): | |
""" | ||
Refer to TraceFactory.create_distplot() for docstring | ||
""" | ||
def __init__(self, hist_data, group_labels, | ||
def __init__(self, hist_data, histnorm, group_labels, | ||
bin_size, curve_type, colors, | ||
rug_text, show_hist, show_curve): | ||
self.hist_data = hist_data | ||
self.histnorm = histnorm | ||
self.group_labels = group_labels | ||
self.bin_size = bin_size | ||
self.show_hist = show_hist | ||
|
@@ -5081,7 +5082,7 @@ def make_hist(self): | |
x=self.hist_data[index], | ||
xaxis='x1', | ||
yaxis='y1', | ||
histnorm='probability', | ||
histnorm=self.histnorm, | ||
name=self.group_labels[index], | ||
legendgroup=self.group_labels[index], | ||
marker=dict(color=self.colors[index]), | ||
|
@@ -5108,7 +5109,9 @@ def make_kde(self): | |
self.curve_y[index] = (scipy.stats.gaussian_kde | ||
(self.hist_data[index]) | ||
(self.curve_x[index])) | ||
self.curve_y[index] *= self.bin_size[index] | ||
|
||
if self.histnorm == 'probability': | ||
|
||
self.curve_y[index] *= self.bin_size[index] | ||
|
||
for index in range(self.trace_number): | ||
curve[index] = dict(type='scatter', | ||
|
@@ -5143,7 +5146,9 @@ def make_normal(self): | |
/ 500 for x in range(500)] | ||
self.curve_y[index] = scipy.stats.norm.pdf( | ||
self.curve_x[index], loc=mean[index], scale=sd[index]) | ||
self.curve_y[index] *= self.bin_size[index] | ||
|
||
if self.histnorm == 'probability': | ||
self.curve_y[index] *= self.bin_size[index] | ||
|
||
for index in range(self.trace_number): | ||
curve[index] = dict(type='scatter', | ||
|
@@ -5621,4 +5626,3 @@ def make_table_annotations(self): | |
font=dict(color=font_color), | ||
showarrow=False)) | ||
return annotations | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yankev can you add that param to the docstring as well (so around line 4039)