Search code examples
pythonubuntuseabornkaggle

Trouble using factorplot method of Seaborn


I am trying to run a Python notebook (link). At line In [18]: where author plot some data using Seaborn I am getting an error

ValueError: 'c' argument has 12 elements, which is not acceptable for use with 'x' with size 0, 'y' with size 0.

In [18]:

import seaborn as sns

# sales trends
sns.factorplot(data = train_store, x = 'Month', y = "Sales", 
               col = 'StoreType', # per store type in cols
               palette = 'plasma',
               hue = 'StoreType',
               row = 'Promo', # per promo in the store in rows
               color = c)

Seaborn Version:

seaborn==0.9.0

I looked at the web about this error but couldn't find anything useful. Please guide me in the right direction.

Update

Here is the minimal code for testing

import pickle
import seaborn as sns
# seaborn==0.9.0

with open('train_store', 'rb') as f:
    train_store = pickle.load(f)

c = '#386B7F' # basic color for plots

# sales trends
sns.factorplot(data = train_store, x = 'Month', y = "Sales", 
               col = 'StoreType', # per store type in cols
               palette = 'plasma',
               hue = 'StoreType',
               row = 'Promo', # per promo in the store in rows
               color = c)

Link to train_store data file: Link 1


Solution

  • I had to make following changes in order to fix the issue

    sns.factorplot(data = train_store, x = 'Month', y = "Sales", 
                   row = 'Promo',     # per promo in the store in rows
                   col = 'StoreType' # per store type in cols
                   )