Skip to content

Commit 4622afd

Browse files
authored
Merge pull request #15017 from meeseeksmachine/auto-backport-of-pr-15007-on-v3.1.x
Backport PR #15007 on branch v3.1.x (FIX: support pandas 0.25)
2 parents d11ab35 + ef9d8b1 commit 4622afd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,13 @@ def _check_1d(x):
13991399
return np.atleast_1d(x)
14001400
else:
14011401
try:
1402-
x[:, None]
1402+
ndim = x[:, None].ndim
1403+
# work around https://github.com/pandas-dev/pandas/issues/27775
1404+
# which mean the shape is not as expected. That this ever worked
1405+
# was an unintentional quirk of pandas the above line will raise
1406+
# an exception in the future.
1407+
if ndim < 2:
1408+
return np.atleast_1d(x)
14031409
return x
14041410
except (IndexError, TypeError):
14051411
return np.atleast_1d(x)

lib/matplotlib/tests/test_axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5522,6 +5522,12 @@ def test_pandas_errorbar_indexing(pd):
55225522
ax.errorbar('x', 'y', xerr='xe', yerr='ye', data=df)
55235523

55245524

5525+
def test_pandas_index_shape(pd):
5526+
df = pd.DataFrame({"XX": [4, 5, 6], "YY": [7, 1, 2]})
5527+
fig, ax = plt.subplots()
5528+
ax.plot(df.index, df['YY'])
5529+
5530+
55255531
def test_pandas_indexing_hist(pd):
55265532
ser_1 = pd.Series(data=[1, 2, 2, 3, 3, 4, 4, 4, 4, 5])
55275533
ser_2 = ser_1.iloc[1:]

0 commit comments

Comments
 (0)