@@ -582,8 +582,8 @@ def test_relplot_weighted_estimator(self, long_df):
582
582
583
583
g = relplot (data = long_df , x = "a" , y = "y" , weights = "x" , kind = "line" )
584
584
ydata = g .ax .lines [0 ].get_ydata ()
585
- for i , label in enumerate (g . ax . get_xticklabels ( )):
586
- pos_df = long_df [long_df ["a" ] == label . get_text () ]
585
+ for i , level in enumerate (categorical_order ( long_df [ "a" ] )):
586
+ pos_df = long_df [long_df ["a" ] == level ]
587
587
expected = np .average (pos_df ["y" ], weights = pos_df ["x" ])
588
588
assert ydata [i ] == pytest .approx (expected )
589
589
@@ -1072,8 +1072,8 @@ def test_weights(self, long_df):
1072
1072
1073
1073
ax = lineplot (long_df , x = "a" , y = "y" , weights = "x" )
1074
1074
vals = ax .lines [0 ].get_ydata ()
1075
- for i , label in enumerate (ax . get_xticklabels ( )):
1076
- pos_df = long_df . loc [long_df ["a" ] == label . get_text () ]
1075
+ for i , level in enumerate (categorical_order ( long_df [ "a" ] )):
1076
+ pos_df = long_df [long_df ["a" ] == level ]
1077
1077
expected = np .average (pos_df ["y" ], weights = pos_df ["x" ])
1078
1078
assert vals [i ] == pytest .approx (expected )
1079
1079
0 commit comments