X Tutup
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`bar` now returns rectangles of negative height or width if the corresponding input is negative
```````````````````````````````````````````````````````````````````````````````````````````````

`plt.bar` used to normalize the coordinates of the rectangles that it created,
to keep their height and width positives, even if the corresponding input was
negative. This normalization has been removed to permit a simpler computation
of the correct `sticky_edges` to use.
6 changes: 0 additions & 6 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,12 +2112,6 @@ def make_iterable(x):

args = zip(left, bottom, width, height, color, edgecolor, linewidth)
for l, b, w, h, c, e, lw in args:
if h < 0:
b += h
h = abs(h)
if w < 0:
l += w
w = abs(w)
r = mpatches.Rectangle(
xy=(l, b), width=w, height=h,
facecolor=c,
Expand Down
12 changes: 0 additions & 12 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4358,18 +4358,6 @@ def test_rc_major_minor_tick():
assert yax._minor_tick_kw['tick2On'] == True


@cleanup
def test_bar_negative_width():
fig, ax = plt.subplots()
res = ax.bar(range(1, 5), range(1, 5), width=-1)
assert_equal(len(res), 4)
for indx, b in enumerate(res):
assert_equal(b._x, indx)
assert_equal(b._width, 1)
assert_equal(b._height, indx + 1)


@cleanup
def test_square_plot():
x = np.arange(4)
y = np.array([1., 3., 5., 7.])
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def test_rotate_rect():
assert_almost_equal(rect1.get_verts(), new_verts)


def test_negative_rect():
# These two rectangles have the same vertices, but starting from a
# different point. (We also drop the last vertex, which is a duplicate.)
pos_vertices = Rectangle((-3, -2), 3, 2).get_verts()[:-1]
neg_vertices = Rectangle((0, 0), -3, -2).get_verts()[:-1]
assert_array_equal(np.roll(neg_vertices, 2, 0), pos_vertices)


@image_comparison(baseline_images=['clip_to_bbox'])
def test_clip_to_bbox():
fig = plt.figure()
Expand Down
X Tutup