0
votes

So I'm dealing with an analysis on donations. I have dates for September and the total sum of donations on that date i.e. Sept 17th $1000, Sept 18th $2000 etc. I have all this info in a Dataframe. Now I want to see if there is a relation between the day of the week and the amount donated. For this I want to make a bar graph that has a different color for each day of the week (Mon-Fri) on top of the graph I made for the donation and dates graph.

How do I do that? I already have the dataframe that contains Date, Amount Donated, Day of the Week. How do I plot this out? I can use pandas and seaborn

2
You need to give more info; here's how to make a complete question: stackoverflow.com/help/mcve - EHB

2 Answers

0
votes

As was already mentioned in the comments: we need a sample of your data(frame) and more precise description of what you want to achieve.
However, until then my first guessed hint would be:

df = df.set_index('date')

fig, axs = plt.subplots(2)
df.amount.plot(ax=axs[1])
df.groupby('weekday').mean().plot(kind='bar', ax=axs[0])
0
votes

Make a list of 7 colors and use it

color_x = ["white", "red", "yellow", "blue", "purple", "green", "black"]
ax = df[b].plot.bar(label=b, color = color_x)

example:

1

(ofcourse don't use white :), just left it this way to correspond with the image )

To get specific colors for specific days, you can do this:

df['WEEKDAY'] = pd.to_datetime(df['date']).dt.dayofweek
firstday = df.iloc[0]['WEEKDAY']  # monday = 0
                if  firstday == 0:
                    color_x = [COLOR_weekday, COLOR_weekday, COLOR_weekday, COLOR_weekday, COLOR_weekday, COLOR_weekend, COLOR_weekend]
                elif firstday == 1:
                    color_x = [COLOR_weekday, COLOR_weekday, COLOR_weekday, COLOR_weekday, COLOR_weekend, COLOR_weekend, COLOR_weekday]
               (etc)