Skip to content

Commit 3620080

Browse files
author
nicolas.rebena
committed
TST: Split test for pandas-dev#15912
Separate the test for pandas-dev#7612 and pandas-dev#22334, that are about string index, and test for pandas-dev#15912, about multiindex.
1 parent 7e67f99 commit 3620080

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

pandas/tests/plotting/test_frame.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -2997,9 +2997,8 @@ def test_secondary_axis_font_size(self, method):
29972997

29982998
@pytest.mark.slow
29992999
def test_x_string_values_ticks(self):
3000-
# GH: 7612
3001-
# GH: 22334
3002-
# GH: 15912
3000+
# Test if string plot index have a fixed xtick position
3001+
# GH: 7612, GH: 22334
30033002
df = pd.DataFrame({'sales': [3, 2, 3],
30043003
'visits': [20, 42, 28],
30053004
'day': ['Monday', 'Tuesday', 'Wednesday']})
@@ -3012,6 +3011,24 @@ def test_x_string_values_ticks(self):
30123011
assert labels_position['Tuesday'] == 1.0
30133012
assert labels_position['Wednesday'] == 2.0
30143013

3014+
@pytest.mark.slow
3015+
def test_x_multiindex_values_ticks(self):
3016+
# Test if multiindex plot index have a fixed xtick position
3017+
# GH: 15912
3018+
index = pd.MultiIndex.from_product([[2012, 2013], [1, 2]])
3019+
df = pd.DataFrame(np.random.randn(4, 2),
3020+
columns=['A', 'B'],
3021+
index=index)
3022+
ax = df.plot()
3023+
ax.set_xlim(-1, 4)
3024+
xticklabels = [t.get_text() for t in ax.get_xticklabels()]
3025+
labels_position = dict(zip(xticklabels, ax.get_xticks()))
3026+
# Testing if the label stayed at the right position
3027+
assert labels_position['(2012, 1)'] == 0.0
3028+
assert labels_position['(2012, 2)'] == 1.0
3029+
assert labels_position['(2013, 1)'] == 2.0
3030+
assert labels_position['(2013, 2)'] == 3.0
3031+
30153032

30163033
def _generate_4_axes_via_gridspec():
30173034
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)