Skip to content

Commit 940bbb5

Browse files
authored
TST/VIZ: add test for legend colors for DataFrame with duplicate column labels #11136 (#32451)
1 parent f3859cb commit 940bbb5

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
@@ -3316,6 +3316,16 @@ def test_missing_markers_legend_using_style(self):
33163316
self._check_legend_labels(ax, labels=["A", "B", "C"])
33173317
self._check_legend_marker(ax, expected_markers=[".", ".", "."])
33183318

3319+
def test_colors_of_columns_with_same_name(self):
3320+
# ISSUE 11136 -> https://github.com/pandas-dev/pandas/issues/11136
3321+
# Creating a DataFrame with duplicate column labels and testing colors of them.
3322+
df = pd.DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
3323+
df1 = pd.DataFrame({"a": [2, 4, 6]})
3324+
df_concat = pd.concat([df, df1], axis=1)
3325+
result = df_concat.plot()
3326+
for legend, line in zip(result.get_legend().legendHandles, result.lines):
3327+
assert legend.get_color() == line.get_color()
3328+
33193329

33203330
def _generate_4_axes_via_gridspec():
33213331
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)