Skip to content
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

BUG: Extra color introduced with plot. #20726

Closed
wuhaochen opened this issue Apr 17, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@wuhaochen
Copy link
Contributor

commented Apr 17, 2018

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

This comment has been minimized.

Copy link
Contributor Author

commented Apr 17, 2018

I can send a PR to fix this.

@anushreejain98

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2018

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
You can’t perform that action at this time.