Joey
Joey

Reputation: 934

How to set more tick marks on a twin y axis in matplotlib

I'm trying to get 8 tick marks on a twin axis but it will only give me 6... any ideas?

ax2 = plt.twiny()

a = np.arange(-4610, 32270, 4610)

ax2.set_xticklabels(np.arange(min(a), max(a), 4610))

my logic is that 32270/4610 = 8.....

so this should give me 8 tick labels right?

Upvotes: 0

Views: 445

Answers (1)

tmdavison
tmdavison

Reputation: 69223

I think you also need to set the xticks, not just the labels:

ax2.set_xticks(np.arange(min(a), max(a), 4610))

Upvotes: 2

Related Questions