Skip to content

BUG: Extra color introduced with plot. #20726

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

Closed
wuhaochen opened this issue Apr 17, 2018 · 3 comments · Fixed by #20727
Closed

BUG: Extra color introduced with plot. #20726

wuhaochen opened this issue Apr 17, 2018 · 3 comments · Fixed by #20727
Labels
Milestone

Comments

@wuhaochen
Copy link
Contributor

User reported in StackOverflow: https://stackoverflow.com/questions/49887076/matplotlib-error-while-coloring-barplot-with-list#49887076

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame(np.abs(np.random.randn(48, 4)), columns=list("ABCD"))

color_list = plt.cm.gnuplot(np.linspace(0,1,16))

df.A.plot.bar( figsize=(16,7), color=color_list)
plt.axvline(15.5, c="black", lw=1)
plt.axvline(31.5, c="black", lw=1)
plt.plot()

Problem description

This bug happens when single color is needed for plotting but an array is provided.
In the end of _get_standard_colors function in plotting/_style.py. An extra first item will be added to the color array which caused the circular misbehaved in such case.
image

Expected Output

The bar 17 should have the same color as the bar 1.

@wuhaochen
Copy link
Contributor Author

I can send a PR to fix this.

@anushreejain98
Copy link

anushreejain98 commented May 9, 2018


*error:this line has been written twice,removing may fix it

plt.axvline(15.5, c="black", lw=1)
plt.axvline(31.5, c="black", lw=1)

@wuhaochen
Copy link
Contributor Author

This is a confirmed bug, the lines you pointed out are used to plot the two separating vertical lines and they are irrelevant to the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants