x = np.linspace(0, 5, N)
y = x ** 2
fig, ax = plt.subplots()
ax.plot(x, y)
minor_locator = AutoMinorLocator(2)
ax.xaxis.set_minor_locator(minor_locator)
plt.grid(which='minor')
plt.show()
How can i set the location of minor ticks in matplotlib