Skip to content

Commit

Permalink
Lukas' tidy suggestion for Hist1dPlot._calculate_bins()
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamOrmondroyd committed Mar 16, 2024
1 parent ae96746 commit 71c7bac
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions anesthetic/plotting/_matplotlib/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,10 @@ def __init__(
super().__init__(data, bins=bins, bottom=bottom, **kwargs)

def _calculate_bins(self, data, bins):
nd_values = data.infer_objects(copy=False)._get_numeric_data()
values = np.ravel(nd_values)
values = values[~isna(values)]
if self._bin_range is None:
q = self.kwds.get('q', 5)
q = quantile_plot_interval(q=q)
weights = self.weights
xmin = quantile(values, q[0], weights)
xmax = quantile(values, q[-1], weights)
xmin, xmax = data.quantile(q).to_numpy().ravel()
self._bin_range = (xmin, xmax)
bins = super()._calculate_bins(data, bins)
return bins
Expand Down

0 comments on commit 71c7bac

Please sign in to comment.