Skip to content

Commit 8bd0842

Browse files
committed
TST: Improve test explanation
1 parent 71de5e2 commit 8bd0842

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/plotting/test_frame.py

+10
Original file line numberDiff line numberDiff line change
@@ -3367,24 +3367,34 @@ def test_colors_of_columns_with_same_name(self):
33673367
@pytest.mark.parametrize("method", ["bar", "barh"])
33683368
def test_bar_ticklabel_consistence(self, method):
33693369
# Draw two consecutiv bar plot with consistent ticklabels
3370+
# The labels positions should not move between two drawing on the same axis
33703371
# GH: 26186
33713372
def get_main_axis(ax):
33723373
if method == "barh":
33733374
return ax.yaxis
33743375
elif method == "bar":
33753376
return ax.xaxis
33763377

3378+
# Plot the first bar plot
33773379
data = {"A": 0, "B": 3, "C": -4}
33783380
df = pd.DataFrame.from_dict(data, orient="index", columns=["Value"])
33793381
ax = getattr(df.plot, method)()
33803382
ax.get_figure().canvas.draw()
3383+
3384+
# Retrieve the label positions for the first drawing
33813385
xticklabels = [t.get_text() for t in get_main_axis(ax).get_ticklabels()]
33823386
label_positions_1 = dict(zip(xticklabels, get_main_axis(ax).get_ticklocs()))
3387+
3388+
# Modify the dataframe order and values and plot on same axis
33833389
df = df.sort_values("Value") * -2
33843390
ax = getattr(df.plot, method)(ax=ax, color="red")
33853391
ax.get_figure().canvas.draw()
3392+
3393+
# Retrieve the label positions for the second drawing
33863394
xticklabels = [t.get_text() for t in get_main_axis(ax).get_ticklabels()]
33873395
label_positions_2 = dict(zip(xticklabels, get_main_axis(ax).get_ticklocs()))
3396+
3397+
# Assert that the label positions did not change between the plotting
33883398
assert label_positions_1 == label_positions_2
33893399

33903400
def test_bar_numeric(self):

0 commit comments

Comments
 (0)