Encountered a problem whilst plotting from GDP dataset:
As I trying to plot, I cannot figure out how to take more than 1 year:
plt.figure(figsize=(14,6))
gdp = sns.lineplot(x=df_gdp['Country Name'], y=df_gdp['1995'], marker='o', color='mediumvioletred', sort=False)
for item in gdp.get_xticklabels():
item.set_rotation(45)
plt.xticks(ha='right',fontweight='light',fontsize='large')
output:
How to plot all years on X, amount on Y and lines as each country ? How to modify Y stick to shown whole digits, not only 1-2-3-4-5-6 and lell
You need to transform your dataframe to "long form" format, then pass the relevant column names to lineplot
df2 = df.melt(id_vars=['Country Name'], var_name='year', value_name='GDP')
sns.lineplot(x='year', y='GDP', hue='Country Name', data=df2)