Skip to content

Commit

Permalink
fix bar width
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Oct 29, 2024
1 parent c0bbdd7 commit 39d9575
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion holoviews/plotting/bokeh/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def get_data(self, element, ranges, style):
if is_dt:
width *= xdiff.astype('timedelta64[ms]').astype(np.int64)
else:
width /= xdiff
width = width * xdiff if np.min(xdiff) < 1 else width / xdiff
width = np.min(width)
else:
grouped = element.groupby(group_dim, group_type=Dataset,
Expand Down
7 changes: 7 additions & 0 deletions holoviews/tests/plotting/bokeh/test_barplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,10 @@ def test_bar_stacked_stack_variable_sorted(self):
bars = Bars(df, kdims=["a", "b"], vdims=["c"]).opts(stacked=True)
plot = bokeh_renderer.get_plot(bars)
assert plot.handles["glyph"].width == 0.8

def test_bar_narrow_non_monotonous_xvals(self):
# Tests regression: https://github.com/holoviz/hvplot/issues/1450
dic = {"ratio": [0.82, 1.11, 3, 6], "count": [1, 2, 1, 3]}
bars = Bars(dic, kdims=["ratio"], vdims=["count"])
plot = bokeh_renderer.get_plot(bars)
assert np.isclose(plot.handles["glyph"].width, 0.23200000000000012)

0 comments on commit 39d9575

Please sign in to comment.