Last answered:

16 Nov 2023

Posted on:

16 Nov 2023

1

Jupyter Color Valure error

it shows ValueError: 'rgbwymc' is not a valid color value. Errro: 

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[49], line 8
      6 df_used_cars
      7 plt.figure(figsize = (9,6))
----> 8 plt.bar(x = df_used_cars["Brand"],
      9        height = df_used_cars["Cars Listings"],
     10        color = "rgbwymc")
     11 plt.xticks(rotation = 45)
     12 plt.show()

File D:\Programfiles\Anaconda\Lib\site-packages\matplotlib\pyplot.py:2439, in bar(x, height, width, bottom, align, data, **kwargs)
   2435 @_copy_docstring_and_deprecators(Axes.bar)
   2436 def bar(
   2437         x, height, width=0.8, bottom=None, *, align='center',
   2438         data=None, **kwargs):
-> 2439     return gca().bar(
   2440         x, height, width=width, bottom=bottom, align=align,
   2441         **({"data": data} if data is not None else {}), **kwargs)

File D:\Programfiles\Anaconda\Lib\site-packages\matplotlib\__init__.py:1446, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
   1443 @functools.wraps(func)
   1444 def inner(ax, *args, data=None, **kwargs):
   1445     if data is None:
-> 1446         return func(ax, *map(sanitize_sequence, args), **kwargs)
   1448     bound = new_sig.bind(ax, *args, **kwargs)
   1449     auto_label = (bound.arguments.get(label_namer)
   1450                   or bound.kwargs.get(label_namer))

File D:\Programfiles\Anaconda\Lib\site-packages\matplotlib\axes\_axes.py:2433, in Axes.bar(self, x, height, width, bottom, align, **kwargs)
   2431 linewidth = itertools.cycle(np.atleast_1d(linewidth))
   2432 hatch = itertools.cycle(np.atleast_1d(hatch))
-> 2433 color = itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
   2434                         # Fallback if color == "none".
   2435                         itertools.repeat('none'))
   2436 if edgecolor is None:
   2437     edgecolor = itertools.repeat(None)

File D:\Programfiles\Anaconda\Lib\site-packages\matplotlib\colors.py:471, in to_rgba_array(c, alpha)
    468     pass
    470 if isinstance(c, str):
--> 471     raise ValueError(f"{c!r} is not a valid color value.")
    473 if len(c) == 0:
    474     return np.zeros((0, 4), float)

1 answers ( 0 marked as helpful)
Posted on:

16 Nov 2023

0

Here is my code: import pandas as pd
import matplotlib.pyplot as plt 
import seaborn as sns
sns.set()
df_used_cars = pd.read_csv("C:/Users/Rezowan/Desktop/bar_chart_data.csv")
df_used_cars
plt.figure(figsize = (9,6))
plt.bar(x = df_used_cars["Brand"],
       height = df_used_cars["Cars Listings"],
       color = "rgbwymc")
plt.xticks(rotation = 45)
plt.show()

Submit an answer