Can someone help explain to me why this box plot is showing lines in my top two, and I had to set my limit to 12 to show the top ten? I use this code earlier in my assignment and nothing like this shows up.
Code as follows:
#Setting up enviornment
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
df = pd.read_csv('Video_Games.csv')
%matplotlib inline
#Most sucessful games NA after 2010
#Boolean Filtering for year
filtered_df = df[df[('Year_of_Release')] > 2010]
#Bar Chart creation
sns.barplot(x='Name',
y='NA_Sales',
data = filtered_df.nlargest(12, 'NA_Sales'))
plt.xticks(rotation=90)
plt.title('Most Successful Games in North America by Revenue')
plt.xlabel('Game Title')
plt.ylabel('Revenue (in the Millions)')
plt.rc('xtick', labelsize=8)
plt.grid(axis="y")
Everything else about it is fine, just don’t understand why the lines show up, and why I need to set data = filtered_df.nlargest(12, ‘NA_Sales’) to 12 to show the top ten. Can anyone help?
>Solution :
Use errorbar=None as parameter of sns.barplot to remove the error bar:
sns.barplot(x='Name',
y='NA_Sales',
data = filtered_df.nlargest(12, 'NA_Sales'),
errorbar=None)
