Skip to content

Commit

Permalink
bug correction in plots
Browse files Browse the repository at this point in the history
- histogram bin size return was incorrect
- now recalculates the number of bins to approximate the desired binsize
  • Loading branch information
marcoalopez committed Apr 6, 2020
1 parent 1b163c5 commit 3d00df5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions grain_size_tools/GrainSizeTools_script.py
Expand Up @@ -219,6 +219,7 @@ def summarize(data, avg=('amean', 'gmean', 'median', 'mode'), ci_level=0.95,
print('============================================================================')
print('DISTRIBUTION FEATURES')
print('============================================================================')
print('Sample size (n) = {}' . format(len(data)))
print('Standard deviation = {:0.2f} (1-sigma)' .format(std))
if 'median' in avg:
print('Interquartile range (IQR) = {:0.2f}' .format(iqr))
Expand Down
4 changes: 3 additions & 1 deletion grain_size_tools/plot.py
Expand Up @@ -100,6 +100,8 @@ def distribution(data,
fig, ax = plt.subplots(**fig_kw)

if 'hist' in plot:
if isinstance(binsize, (int, float)):
binsize = int(np.ceil((data.max() - data.min()) / binsize))
y_values, bins, __ = ax.hist(data,
bins=binsize,
range=(data.min(), data.max()),
Expand All @@ -109,7 +111,7 @@ def distribution(data,
alpha=0.7)
print('=======================================')
print('Number of classes = ', len(bins) - 1)
print('binsize = ', round(bins[1], 2))
print('binsize = ', round(bins[1] - bins[0], 2))
print('=======================================')

if 'kde' in plot:
Expand Down

0 comments on commit 3d00df5

Please sign in to comment.