String of single character colors deprecated
in
The Complete Data Visualization Course with Python, R, Tableau, and Excel
/
Bar Chart - Python - How to Create a Bar Chart
Just wanted to let the community know that using a string of single characters for colors will be removed soon (Using color = "rgbwymc"):
MatplotlibDeprecationWarning: Using a string of single character colors as a color sequence is deprecated since 3.2 and will be removed two minor releases later. Use an explicit list instead.
plt.bar(x = df_used_cars["Brand"], height = df_used_cars["Cars Listings"], color = "rgbwymc")
1 answers ( 0 marked as helpful)
Hi Samantha,
thanks for reaching out! It has been deprecated unfortunately in the newer versions of the library. Instead you can use the full names of colors in the list, like so:
# Define colors explicitly as a list
colors = ['red', 'green', 'blue', 'white', 'yellow', 'magenta', 'cyan']
# Plotting
plt.bar(x=df_used_cars["Brand"], height=df_used_cars["Cars Listings"], color=colors)
plt.show()
Best,
365 Eli