Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08ee273

Browse files
author
Nic Eggert
committed
Fix bug in horizontal step histograms
1 parent 2617d05 commit 08ee273

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

lib/matplotlib/axes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8494,10 +8494,11 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
84948494
if log:
84958495
y[y < minimum] = minimum
84968496
if orientation == 'horizontal':
8497-
x, y = y, x
8498-
8499-
xvals.append(x.copy())
8500-
yvals.append(y.copy())
8497+
xvals.append(y.copy())
8498+
yvals.append(x.copy())
8499+
else:
8500+
xvals.append(x.copy())
8501+
yvals.append(y.copy())
85018502

85028503
if fill:
85038504
# add patches in reverse order so that when stacking,

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,16 @@ def test_hist_step():
10881088
ax.set_xlim(-1, 5)
10891089

10901090

1091+
@image_comparison(baseline_images=['hist_step_horiz'], extensions=['png'])
1092+
def test_hist_step_horiz():
1093+
# make some data
1094+
d1 = np.linspace(0, 10, 50)
1095+
d2 = np.linspace(1, 3, 20)
1096+
fig = plt.figure()
1097+
ax = fig.add_subplot(111)
1098+
ax.hist( (d1, d2), histtype="step", orientation="horizontal")
1099+
1100+
10911101
@image_comparison(baseline_images=['hist_stacked_weights'])
10921102
def test_hist_stacked_weighted():
10931103
# make some data

0 commit comments

Comments
 (0)