<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 seaborn.countplot
Bar graphs are useful for displaying relationships between categorical data and at least one numerical variable. seaborn.countplot is a barplot where the dependent variable is the number of instances of each instance of the independent variable.
dataset
Step1:  For the bar plot, let's look at the number of movies in each category, allowing each movie to be counted more than once.
Step2:  Basic plot
Step3:  color by a category
Step4:  make plot horizontal
Step5:  Saturation
Step6:  Various palettes
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.rcParams['figure.figsize'] = (20.0, 10.0)
df = pd.read_csv('../../../datasets/movie_metadata.csv')
df.head()
Explanation: seaborn.countplot
Bar graphs are useful for displaying relationships between categorical data and at least one numerical variable. seaborn.countplot is a barplot where the dependent variable is the number of instances of each instance of the independent variable.
dataset: IMDB 5000 Movie Dataset
End of explanation
# split each movie's genre list, then form a set from the unwrapped list of all genres
categories = set([s for genre_list in df.genres.unique() for s in genre_list.split("|")])
# one-hot encode each movie's classification
for cat in categories:
    df[cat] = df.genres.transform(lambda s: int(cat in s))
# drop other columns
df = df[['director_name','genres','duration'] + list(categories)]
df.head()
# convert from wide to long format and remove null classificaitons
df = pd.melt(df,
             id_vars=['duration'],
             value_vars = list(categories),
             var_name = 'Category',
             value_name = 'Count')
df = df.loc[df.Count>0]
# add an indicator whether a movie is short or long, split at 100 minutes runtime
df['islong'] = df.duration.transform(lambda x: int(x > 100))
# sort in descending order
#df = df.loc[df.groupby('Category').transform(sum).sort_values('Count', ascending=False).index]
df.head()
Explanation: For the bar plot, let's look at the number of movies in each category, allowing each movie to be counted more than once.
End of explanation
p = sns.countplot(data=df, x = 'Category')
Explanation: Basic plot
End of explanation
p = sns.countplot(data=df,
                  x = 'Category',
                  hue = 'islong')
Explanation: color by a category
End of explanation
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong')
Explanation: make plot horizontal
End of explanation
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.5)
Explanation: Saturation
End of explanation
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'deep')
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'muted')
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'pastel')
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'bright')
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'dark')
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'colorblind')
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = ((50/255, 132/255.0, 191/255.0), (255/255.0, 232/255.0, 0/255.0)))
p = sns.countplot(data=df,
                  y = 'Category',
                  hue = 'islong',
                  saturation=.9,
                  palette = 'Dark2')
help(sns.color_palette)
help(sns.countplot)
sns.set(rc={"axes.facecolor":"#ccddff",
            "axes.grid":False,
            'axes.labelsize':30,
            'figure.figsize':(20.0, 10.0),
            'xtick.labelsize':25,
            'ytick.labelsize':20})
p = sns.countplot(data=df, x = 'Category')
plt.text(9,2000, "Color Palettes", fontsize = 95, color='black', fontstyle='italic')
p.get_figure().savefig('../../figures/colors.png')
Explanation: Various palettes
End of explanation
<END_TASK>