0

I am new python and I have two columns in a dataframe that i want to plot against date

plt.scatter(thing.date,thing.loc[:,['numbers','more_numbers']])

my intuition is the above should work (because matlab allows for this kind of thing), but it doesn't, and I'm not sure why.

Is there away around this?


I'm hoping to plot these columns for a sequence of 4 dataframes on the same axes - so i'd like to use a command like the above so I can colour the columns from each data frame to make it distinctive.

1 Answer 1

2

Easiest is to do a loop:

fig, ax = plt.subplots()

for col in ['numbers', 'more_numbers']:
    ax.scatter(things.date, things[col], label=col)
    # or
    # things.scatter(x='date', y=col, label=col, ax=ax)

plt.show()
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.