x = np.arange(-0.6, 5.6, 0.2)
y = 2 * x
z = x ** 2
fig, ax = plt.subplots()
ax.plot(x, y, 'bo-')
integers = z % 1 < 1e-06
for X, Y, Z in zip(x[integers], y[integers], z[integers]):
    ax.annotate('{:.0f}'.format(Z), xy=(X, Y), xytext=(-10, 10), ha='right',
        textcoords='offset points', arrowprops=dict(arrowstyle='->', shrinkA=0)
        )
plt.show()
Matplotlib - labelling points (x,y) on a line with a value z