0

I have this series: data:

0      17  
1      25  
2      10  
3      60  
4       0  
5      20  
6     300  
7      50  
8      10  
9      80  
10    100  
11     65  
12    125  
13     50  
14    100  
15    150 

Name: 1, dtype: int64

I wanted to plot an histogram with variable bin size, so I made this:

    filter_values = [0,25,50,60,75,100,150,200,250,300,350]
    out = pd.cut(data."1", bins = filter_values)
    counts = pd.value_counts(out)
    print(counts)

My problem is that when I use counts.plot(kind="hist"), i have not the good label for x axis. I only get them by using a bargraph instead counts.plot(kind="bar"), but I can't get the right order then. I tried to use xticks=counts.index.values[0] but it makes an error, and xticks=filter_values give an odd figure shape as the numbers go far beyond what the plot understand the bins to be.

I also tried counts.hist(), data.hist(), and counts.plot.hist without success. I don't know how to plot correctly the categorical data from counts (it includes as index a pandas categorical index) so, I don't know which process I should apply, if there is a way to plot variable bins directly in data.hist() or data.plot(kind="hist") or data.plot.hist(), or if I am right to build counts, but then how to represent this correctly (with good labels on the xaxis and the right order, not a descending one as in the bar graph.

Ando Jurai
  • 1,003
  • 2
  • 14
  • 29

0 Answers0