i have two DataFrames(Action,Comedy). Action contains two columns(year,rating) ratings columns contains average rating with respect to year. Comedy Dataframe contains same two columns with different mean values.

i merge both dataframe in a total_year Dataframe

Output of total_year

Totle year Output

Now i want to plot total_year on line graph in which X axis should contain year column and Y axis should contain both action and comedy columns.

i can plot only 1 column at a time on Y axis using following code.

total_year[-15:].plot(x='year', y='action' ,figsize=(10,5), grid=True  )

How i can plot both columns on Y axis?

i took this photo from google just to let you know guys i want to draw graph in this way

enter image description here

  • $\begingroup$ i got answer of this Question here $\endgroup$ – Bilal Butt Dec 12 '17 at 14:58

Feeding your column names into the y values argument as a list works for me like so:

total_year[-15:].plot(x='year', y=['action', 'comedy'], figsize=(10,5), grid=True)

Using something like the answer at this link is better and gives you way more control over the labels and whatnot: adding lines with plt.plot()

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.