2

I made some data in dataframe and I wanted to plot them into 1 graph, how do I do that?

I plot them one by one using these codes and here are the results

df.plot(x='MONTH', y='MONTHLY INCOME')
df.plot(x='MONTH', y='MONTHLY EXPENSES')
df.plot(x='MONTH', y='MONTHLY SAVINGS')

graphs https://i.sstatic.net/59kpV.png

Dataframe https://i.sstatic.net/vPiFO.png

1 Answer 1

1

Try using matplotlib.

import matplotlib.pyplot as plt

legend_labels = ['INCOME', 'EXPENSES', 'SAVINGS']
plt.plot(df['MONTH'], df['MONTHLY INCOME'])
plt.plot(df['MONTH'], df['MONTHLY EXPENSES'])
plt.plot(df['MONTH'], df['MONTHLY SAVINGS'])
plt.legend(legend_labels)
plt.show()

Sign up to request clarification or add additional context in comments.

2 Comments

It did work, Thankyou Itzik Shamli!
I am glad :) enjoy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.