Skip to content

Commit 053eea9

Browse files
authored
Merge pull request #15016 from meeseeksmachine/auto-backport-of-pr-15007-on-v2.2.x
Backport PR #15007 on branch v2.2.x (FIX: support pandas 0.25)
2 parents cb1983e + 2681d33 commit 053eea9

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
@@ -2061,7 +2061,13 @@ def _check_1d(x):
20612061
return np.atleast_1d(x)
20622062
else:
20632063
try:
2064-
x[:, None]
2064+
ndim = x[:, None].ndim
2065+
# work around https://github.com/pandas-dev/pandas/issues/27775
2066+
# which mean the shape is not as expected. That this ever worked
2067+
# was an unintentional quirk of pandas the above line will raise
2068+
# an exception in the future.
2069+
if ndim < 2:
2070+
return np.atleast_1d(x)
20652071
return x
20662072
except (IndexError, TypeError):
20672073
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
@@ -5170,6 +5170,12 @@ def test_pandas_errorbar_indexing(pd):
51705170
ax.errorbar('x', 'y', xerr='xe', yerr='ye', data=df)
51715171

51725172

5173+
def test_pandas_index_shape(pd):
5174+
df = pd.DataFrame({"XX": [4, 5, 6], "YY": [7, 1, 2]})
5175+
fig, ax = plt.subplots()
5176+
ax.plot(df.index, df['YY'])
5177+
5178+
51735179
def test_pandas_indexing_hist(pd):
51745180
ser_1 = pd.Series(data=[1, 2, 2, 3, 3, 4, 4, 4, 4, 5])
51755181
ser_2 = ser_1.iloc[1:]

0 commit comments

Comments
 (0)