Last answered:

21 Nov 2022

Posted on:

20 Nov 2022

1

color coding syntax issue

when I use a one color it works, when I try to use the initials that were in the video it seems that it doesn't work and give me an error! how can i solve it?imageimage

2 answers ( 0 marked as helpful)
Instructor
Posted on:

21 Nov 2022

6

Hi Abdelrahman,
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!

Best,
365 Eli

Posted on:

21 Nov 2022

1

Thanks, It worked!

Submit an answer