ValueError: Using a string of single character colors as a color sequence is not supported. The colo
I got this error when I tried to change the color of the columns but don't know how to solve it. Please give my guidance for this error, thanks so much.
ValueError: Using a string of single character colors as a color sequence is not supported. The colors can be passed as an explicit list instead.
Hi Thi Kim,
thanks for reaching out! It seems that the functionality of using a single string as a color has been deprecated in some versions of matplotlib and is no longer supported, that's why you're getting the error. If you'd like to have individual colors for each bar, you can do the following:
1. Have a list of all the colors, using their full names
2. Pass that list for the color argument
Here is some example code:
colors = ["red","green","blue","white","yellow","magenta","cyan"] plt.bar(x = df_used_cars["Brand"], #specify the x axis height = df_used_cars["Cars Listings"], #specify the y axis color = colors)
Let me know if this version works for you or if you have any further questions!
As it says in the last line, it can be used as list instead. So I only adjusted all the initials in their own quotation mark instead of having them all in a single quotation mark, like this:
colors = ["r", "g", "b", "w", "y", "m", "c"]
and that worked
I tried Rafael's approach by using "r" instead of Red, but seems like it output a darker shade, but not as dark as when writing "darkred". "Red" returned me the color without any tint (light), shade (dark) or tone (gray).