Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 200c455

Browse filesBrowse files
authored
Merge pull request #8130 from NelleV/v2.0.x
MAINT Backporting of #7995.
2 parents bef5a8e + 2502ee9 commit 200c455
Copy full SHA for 200c455

File tree

Expand file treeCollapse file tree

4 files changed

+15
-18
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+15
-18
lines changed
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
`bar` now returns rectangles of negative height or width if the corresponding input is negative
2+
```````````````````````````````````````````````````````````````````````````````````````````````
3+
4+
`plt.bar` used to normalize the coordinates of the rectangles that it created,
5+
to keep their height and width positives, even if the corresponding input was
6+
negative. This normalization has been removed to permit a simpler computation
7+
of the correct `sticky_edges` to use.

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,12 +2112,6 @@ def make_iterable(x):
21122112

21132113
args = zip(left, bottom, width, height, color, edgecolor, linewidth)
21142114
for l, b, w, h, c, e, lw in args:
2115-
if h < 0:
2116-
b += h
2117-
h = abs(h)
2118-
if w < 0:
2119-
l += w
2120-
w = abs(w)
21212115
r = mpatches.Rectangle(
21222116
xy=(l, b), width=w, height=h,
21232117
facecolor=c,

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
-12Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4358,18 +4358,6 @@ def test_rc_major_minor_tick():
43584358
assert yax._minor_tick_kw['tick2On'] == True
43594359

43604360

4361-
@cleanup
4362-
def test_bar_negative_width():
4363-
fig, ax = plt.subplots()
4364-
res = ax.bar(range(1, 5), range(1, 5), width=-1)
4365-
assert_equal(len(res), 4)
4366-
for indx, b in enumerate(res):
4367-
assert_equal(b._x, indx)
4368-
assert_equal(b._width, 1)
4369-
assert_equal(b._height, indx + 1)
4370-
4371-
4372-
@cleanup
43734361
def test_square_plot():
43744362
x = np.arange(4)
43754363
y = np.array([1., 3., 5., 7.])

‎lib/matplotlib/tests/test_patches.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_patches.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ def test_rotate_rect():
8181
assert_almost_equal(rect1.get_verts(), new_verts)
8282

8383

84+
def test_negative_rect():
85+
# These two rectangles have the same vertices, but starting from a
86+
# different point. (We also drop the last vertex, which is a duplicate.)
87+
pos_vertices = Rectangle((-3, -2), 3, 2).get_verts()[:-1]
88+
neg_vertices = Rectangle((0, 0), -3, -2).get_verts()[:-1]
89+
assert_array_equal(np.roll(neg_vertices, 2, 0), pos_vertices)
90+
91+
8492
@image_comparison(baseline_images=['clip_to_bbox'])
8593
def test_clip_to_bbox():
8694
fig = plt.figure()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.