1313# limitations under the License.
1414
1515import numpy as np
16+ import pandas as pd
1617import pandas ._testing as tm
1718import pytest
1819
@@ -235,6 +236,18 @@ def test_sampling_plot_args_random_state():
235236 tm .assert_almost_equal (ax_0 .lines [0 ].get_data ()[1 ], ax_2 .lines [0 ].get_data ()[1 ])
236237
237238
239+ def test_sampling_preserve_ordering ():
240+ df = bpd .DataFrame ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ], index = [1 , 3 , 4 , 2 , 0 ])
241+ pd_df = pd .DataFrame ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ], index = [1 , 3 , 4 , 2 , 0 ])
242+ ax = df .plot .line ()
243+ pd_ax = pd_df .plot .line ()
244+ tm .assert_almost_equal (ax .get_xticks (), pd_ax .get_xticks ())
245+ tm .assert_almost_equal (ax .get_yticks (), pd_ax .get_yticks ())
246+ for line , pd_line in zip (ax .lines , pd_ax .lines ):
247+ # Compare y coordinates between the lines
248+ tm .assert_almost_equal (line .get_data ()[1 ], pd_line .get_data ()[1 ])
249+
250+
238251@pytest .mark .parametrize (
239252 ("kind" , "col_names" , "kwargs" ),
240253 [
@@ -251,7 +264,7 @@ def test_sampling_plot_args_random_state():
251264 marks = pytest .mark .xfail (raises = ValueError ),
252265 ),
253266 pytest .param (
254- "uknown " ,
267+ "bar " ,
255268 ["int64_col" , "int64_too" ],
256269 {},
257270 marks = pytest .mark .xfail (raises = NotImplementedError ),
0 commit comments