1

I have tuple list as [(2014, 30, 15), (2015, 10, 20), (2007, 5, 3)]. Now I want to plot bar graph in pandas in such a way that first index of each tuple on X axis and corresponding bars for second and third element on y axis. so for first tuple 2014 on x-axis and two bar for 30 and 15 respectively on y-axis. How can I achieve this using pandas plot function or in python matplotlib?

1 Answer 1

4

sounds like you want:

df = pd.DataFrame( [(2014, 30, 15), (2015, 10, 20), (2007, 5, 3)] )
df.columns = ['year','v1','v2']
df.set_index('year', inplace=True)
df.plot(kind='bar')

which gives:

enter image description here

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

Comments

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.