Skip to content

Commit

Permalink
fix and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Aug 7, 2024
1 parent d0eee67 commit 6e35d58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2380,9 +2380,8 @@ def hist(self, x=None, y=None, data=None):
.opts(compat_opts, backend=self._backend_compat)
)

if 'bin_range' not in self.kwds and 'axiswise' not in self._norm_opts:
if 'bin_range' not in self.kwds and not self._norm_opts.get('axiswise'):
ranges = []
ymin, ymax = ys.min(), ys.max()
for col in y:
ys = data[col]
ymin, ymax = (ys.min(), ys.max())
Expand Down
16 changes: 16 additions & 0 deletions hvplot/tests/testcharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,22 @@ def test_histogram_wide_set_group_label(self):
plot = self.df.hvplot.hist(group_label='Test')
assert plot.kdims[0].name == 'Test'

def test_histogram_subplots_no_shared_axes(self):
plots = self.df.hvplot.hist(subplots=True, shared_axes=False)
plot_0 = plots.grid_items()[0, 0][1]
plot_1 = plots.grid_items()[0, 1][1]
assert not plot_0.opts['axiswise']
assert plot_0.range('x') == (1, 5)
assert plot_1.range('y') == (2, 6)

def test_histogram_subplots_shared_axes(self):
plots = self.df.hvplot.hist(subplots=True, shared_axes=True)
plot_0 = plots.grid_items()[0, 0][1]
plot_1 = plots.grid_items()[0, 1][1]
assert plot_0.opts['axiswise']
assert plot_0.range('x') == (1, 6)
assert plot_1.range('y') == (1, 6)

def test_scatter_color_internally_set_to_dim(self):
altered_df = self.cat_df.copy().rename(columns={'category': 'red'})
plot = altered_df.hvplot.scatter('x', 'y', c='red')
Expand Down

0 comments on commit 6e35d58

Please sign in to comment.