Skip to content

TST/VIZ: add test for legend colors for DataFrame with duplicate column labels #11136 #32451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3316,6 +3316,22 @@ def test_missing_markers_legend_using_style(self):
self._check_legend_labels(ax, labels=["A", "B", "C"])
self._check_legend_marker(ax, expected_markers=[".", ".", "."])

def test_colors_of_columns_with_same_name(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like test_legend_colors_duplicate_labels ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply, i have just made the changes . Can you check if is everything right now?

self,
): # ISSUE 11136 -> https://github.com/pandas-dev/pandas/issues/11136
df = pd.DataFrame(
{"b": [0, 1, 0], "a": [1, 2, 3]}
) # generate a dataframe with 2 columns
df1 = pd.DataFrame({"a": [2, 4, 6]}) # generate another dataframe
df_concat = pd.concat([df, df1], axis=1) # concat two dataframes
a = df_concat.plot() # plotting the concat
for i in range(
len(a.legend_.legendHandles)
): # passing on each label of legend and lines
assert (
a.legend_.legendHandles[i]._color == a.lines[i]._color
) # testing if the color of both are equal


def _generate_4_axes_via_gridspec():
import matplotlib.pyplot as plt
Expand Down