1import matplotlib.pyplot as plt
2import numpy as np
3from matplotlib.ticker import FormatStrFormatter
4
5fig, ax = plt.subplots()
6
7ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
8ax.yaxis.set_ticks(np.arange(-2, 2, 0.25))
9
10x = np.arange(-1, 1, 0.1)
11plt.plot(x, x**2)
12plt.show()