BUG: Extra color introduced with plot. · Issue #20726 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Description
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.
Expected Output
The bar 17 should have the same color as the bar 1.