From 872c7fce09397bbfc8bf5f0f7d1a0c501086e3c1 Mon Sep 17 00:00:00 2001 From: Michael Waskom Date: Wed, 6 Dec 2023 08:22:55 -0500 Subject: [PATCH] Matplotlib backcompat in tests --- tests/test_relational.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_relational.py b/tests/test_relational.py index 06d0860a38..f4f97068a9 100644 --- a/tests/test_relational.py +++ b/tests/test_relational.py @@ -582,8 +582,8 @@ def test_relplot_weighted_estimator(self, long_df): g = relplot(data=long_df, x="a", y="y", weights="x", kind="line") ydata = g.ax.lines[0].get_ydata() - for i, label in enumerate(g.ax.get_xticklabels()): - pos_df = long_df[long_df["a"] == label.get_text()] + for i, level in enumerate(categorical_order(long_df["a"])): + pos_df = long_df[long_df["a"] == level] expected = np.average(pos_df["y"], weights=pos_df["x"]) assert ydata[i] == pytest.approx(expected) @@ -1072,8 +1072,8 @@ def test_weights(self, long_df): ax = lineplot(long_df, x="a", y="y", weights="x") vals = ax.lines[0].get_ydata() - for i, label in enumerate(ax.get_xticklabels()): - pos_df = long_df.loc[long_df["a"] == label.get_text()] + for i, level in enumerate(categorical_order(long_df["a"])): + pos_df = long_df[long_df["a"] == level] expected = np.average(pos_df["y"], weights=pos_df["x"]) assert vals[i] == pytest.approx(expected)