Home > Enterprise >  Change x-axis in pandas histogram
Change x-axis in pandas histogram

Time:12-18

I have a DataFrame with capacity of smartphones

Data example:

index capacity
1 128
2 64
3 256
4 512
5 64
6 32
... ...

I want to build histogram of this data.

I tried do it using:

data.hist(column="capacity", bins=data["capacity"].unique().size, range=(0, max(data["capacity"])), grid=False, edgecolor='black')
plt.show()

Histogram shows amount of smartphones in intervals by 100: what I have

I want it looks like this: what I want

How can I do it?

CodePudding user response:

One option:

df['capacity'].value_counts().plot.bar(rot=0)
  • Related