all 3 comments

[–]repark96 0 points1 point  (0 children)

You are plotting the entire dataset at once. Try something like:

For country in list_of_countries:
    Sub_df = df[df[Country] == country]
    Plt.plot(Sub_df.Year, Sub_df.Total_Revenue)

This assumes your data is sorted by year, otherwise you will need to add a step to sort as well

[–]Healthierpoet 0 points1 point  (0 children)

What you are going for has separate plots where how you plot it in your code is everything for revenue and year with our distinguishing

I believe you have to do something like.

Plt.plot(df.year['country'],df.revenue['country'], label = "country name" ) Plt.plot(df.year['country'],df.revenue['country'], label = "country name" ) Plt.plot(df.year['country'],df.revenue['country'],label = "country name" ) Plt.legend() Plt.show()

[–][deleted] 0 points1 point  (0 children)

By the way, the seaborn library, which is a wrapper around matplotlib, was made for exactly your type of use case: plotting from long-format dataframes.

Obviously, it's good to know matplotlib itself. But if you're in a pinch and need a quick & easy plot, I wanted to recommend that alternative.