1

I am looking to add edit the tick marks on the x-axis of my histogram to show increments of 5, rather than 10.

#ages is a list of ints

plt.hist(ages, bins=20)
plt.show()

When I run this, I get the histogram I desire, but the x-axis ticks/labels go from 0 to 80 by multiples of 10, and I want them to show multiples of 5. Is there a way to manually choose which values are used for the x ticks?

Brent
  • 51
  • 2
  • 10
  • This helped! I was able to manipulate the code there and find my solution. – Brent Jan 22 '19 at 14:59
  • If it helped you can always upvote my comment to show appreciation. – sophros Jan 22 '19 at 15:02
  • I definitely will! But for some reason I don't see your original comment. Also I'm not sure why this was marked duplicate, because the question that you directed me to was not the exact answer I was looking for, but more so a step in the right direction. – Brent Jan 23 '19 at 17:07

1 Answers1

1

This allows to choose an exact range and increment value. Here we start at zero, and go to 85, incrementing by 5.

    plt.xticks(np.arange(0, 85, 5))
Brent
  • 51
  • 2
  • 10