Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ultraplot/axes/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6057,7 +6057,9 @@ def _apply_bar(
kw = self._parse_cycle(n, **kw)
# Adjust x or y coordinates for grouped and stacked bars
w = _not_none(w, np.array([0.8])) # same as mpl but in *relative* units
b = _not_none(b, np.array([0.0])) # same as mpl
b = np.atleast_1d(
_not_none(b, np.array([0.0]))
) # tolerate scalar `bottom`/`left`
if not absolute_width:
w = self._convert_bar_width(x, w)
if stack:
Expand Down
18 changes: 18 additions & 0 deletions ultraplot/tests/test_1dplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ def test_bar_width(rng):
return fig


def test_bar_scalar_bottom():
"""
Regression for #731: pandas dispatches Series.plot(kind="barh") via
matplotlib with a scalar ``bottom`` (or ``left``), which previously hit
``AttributeError: 'int' object has no attribute 'size'`` inside
``_inbounds_xylim``.
"""
# Direct scalar `bottom` / `left`
fig, ax = uplt.subplots()
ax.bar([1, 2, 3], [4, 5, 6], bottom=0)
ax.barh([1, 2, 3], [4, 5, 6], left=0)

# The original failing reproducer from the issue
series = pd.Series({"a": 1, "b": 2, "c": 3})
fig, ax = uplt.subplots()
series.plot(kind="barh", ax=ax[0])


@pytest.mark.mpl_image_compare
def test_bar_vectors():
"""
Expand Down
Loading