Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Box plot has lines for some reason

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")

Output:
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading