0

I'm trying to plot a bar chart of some de-identified transactional banking data using the pandas and matplotlib libraries.

The data looks like this:

data for work

The column named "day" stores the numbers of the days on which the transaction was made, the column named "tr_type" stores the numbers of transactions made on each day, and the column named "average_income" stores the average amount of incomes for each of the different types of transactions.

The task is to display the data of all three columns, which have the largest average amount of incomes, on one graph.

For definiteness, I took the top 5 rows of sorted data. `

slised_two = sliced_df_new.sort_values('average_income', ascending=False).head(5)
slised_two = slised_two.set_index('day')

` For convenience in further plotting, I set a column called "day" as an index. I get this:

data after transformations

Based on this data, I tried to build one graph, but, unfortunately, I did not achieve the result I wanted, because I had to build 2 graphs for normal data display. `

axes = slised_two.plot.bar(rot=0, subplots=True)
axes[1].legend(loc=2) 

` my charts

The question arises, is it possible to build a histogram in such a way that days are displayed on the x-axis, the average amount of incomes is displayed on the y-axis, and at the same time, the transaction number is signed on top of each column?

Lisa
  • 1
  • 3
    Instead of posting a screenshot of the data, please provide a [minimal example](https://stackoverflow.com/help/minimal-reproducible-example) that others can use. – suvayu Nov 10 '22 at 19:28
  • It is possible. I found a solution. Check out this: https://stackoverflow.com/questions/39841733/matplotlib-histogram-how-to-display-the-count-over-the-bar – Thorin Nov 10 '22 at 19:56

0 Answers0