Home > Blockchain >  Plotting top 5 values in Seaborn
Plotting top 5 values in Seaborn

Time:11-20

How to plot the top 5 values that appear to be the biggest in this plot? (Wii,NES,GB,DS,X360)

sns.violinplot(x=df['Global_Sales'],y=df['Platform'],data=df)

enter image description here

CodePudding user response:

Use sort_values with tail:

sns.violinplot(
    x='Global_Sales',
    y='Platform',
    data=df.sort_values('Global_Sales').tail(5))

Or sort_values(ascending=False) with head:

sns.violinplot(
    x='Global_Sales',
    y='Platform',
    data=df.sort_values('Global_Sales', ascending=False).head(5))
  • Related