0

I'm trying to plot time series data where there are multiple points at each time. I want to have timeon the x axis, Amount on the y axis and then color each point by ID i.e. where ID = 344 they would all have the same color etc.

Below is example data i'm using. I'm sure this must exist but I can't find gallery examples on Matplotlib.org

                ID     Amount
Time                        
2015-12-09      344    0.333333
2015-12-10      345    0.333333
2015-12-09      345    0.333333
2015-12-09      344    0.750000
2015-12-09      342    0.583333

Things i've tried include trying to reshape the data as a pivot table (didn't work because there are two duplicate values for ID 344. Groupby, but I've struggled grouping by two columns, I think if I could groupby ID and retain the Time field this would go some way towards solving my problem.

Any help or advice would be massively appreciated.

1 Answer 1

5

Read the docs and look at examples for scatter within pylab or matplotlib

import pylab as pl

fig= pl.figure( figsize=(5,5) )
ax  = fig.add_subplot(111)

ax.scatter(df.index, df.Amount, s=20, c=df.ID)

This can be customized to meet your needs.

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

2 Comments

Thanks for the suggestion, do you know if it's possible to use time stamp data for the x axis in a scatter plot?
It is, but it must first be converted from string to datetime.

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.