Skip to content

Commit ef3915e

Browse files
committed
resolve conflict, use more dat
1 parent 63fc476 commit ef3915e

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,12 +2587,12 @@ def sign(x):
25872587
if err is None:
25882588
endpt = extrema
25892589
elif orientation == "vertical":
2590-
endpt = err[:, 1].max() if yc >= 0 else err[:, 1].min()
2590+
endpt = err[:, 1].max() if dat >= 0 else err[:, 1].min()
25912591
elif orientation == "horizontal":
2592-
endpt = err[:, 0].max() if xc >= 0 else err[:, 0].min()
2592+
endpt = err[:, 0].max() if dat >= 0 else err[:, 0].min()
25932593

25942594
if label_type == "center":
2595-
value = sign(extrema) * length
2595+
value = sign(dat) * length
25962596
elif label_type == "edge":
25972597
value = extrema
25982598

@@ -2604,20 +2604,20 @@ def sign(x):
26042604
xy = endpt, yc
26052605

26062606
if orientation == "vertical":
2607-
xytext = 0, sign(extrema) * padding
2607+
xytext = 0, sign(dat) * padding
26082608
else:
2609-
xytext = sign(extrema) * padding, 0
2609+
xytext = sign(dat) * padding, 0
26102610

26112611
if label_type == "center":
26122612
ha, va = "center", "center"
26132613
elif label_type == "edge":
2614-
if orientation == "vertical" and yc >= 0:
2614+
if orientation == "vertical" and dat >= 0:
26152615
ha, va = "center", "bottom"
2616-
elif orientation == "vertical" and yc < 0:
2616+
elif orientation == "vertical" and dat < 0:
26172617
ha, va = "center", "top"
2618-
elif orientation == "horizontal" and xc >= 0:
2618+
elif orientation == "horizontal" and dat >= 0:
26192619
ha, va = "left", "center"
2620-
elif orientation == "horizontal" and xc < 0:
2620+
elif orientation == "horizontal" and dat < 0:
26212621
ha, va = "right", "center"
26222622

26232623
annotation = self.annotate(fmt % value if lbl is None else lbl,

lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6850,3 +6850,12 @@ def test_bar_label_labels():
68506850
labels = ax.bar_label(rects, labels=['A', 'B'])
68516851
assert labels[0].get_text() == 'A'
68526852
assert labels[1].get_text() == 'B'
6853+
6854+
6855+
def test_multiplot_autoscale():
6856+
fig = plt.figure()
6857+
ax1, ax2 = fig.subplots(2, 1, sharex='all')
6858+
ax1.scatter([1, 2, 3, 4], [2, 3, 2, 3])
6859+
ax2.axhspan(-5, 5)
6860+
xlim = ax1.get_xlim()
6861+
assert np.allclose(xlim, [0.5, 4.5])

0 commit comments

Comments
 (0)