I am trying to annotate text in plots so that they follow the curvature of the line. I have the following plot:
And this is what I want to obtain, if I fix a particular y value for the annotation, for each curve it should place the annotation along the curve at the required slope (i.e. it should follow the curvature of the curve) as shown below:
The reproducible code for the plot without annotations is:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([[53.4, 57.6, 65.6, 72.9],
[60.8, 66.5, 73.1, 83.3],
[72.8, 80.3, 87.2, 99.3],
[90.2, 99.7, 109.1, 121.9],
[113.6, 125.6, 139.8, 152]])
y = np.array([[5.7, 6.4, 7.2, 7.8],
[5.9, 6.5, 7.2, 7.9],
[6.0, 6.7, 7.3, 8.0],
[6.3, 7.0, 7.6, 8.2],
[6.7, 7.5, 8.2, 8.7]])
plt.figure(figsize=(5.15, 5.15))
plt.subplot(111)
for i in range(len(x)):
plt.plot(x[i, :] ,y[i, :])
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
How to place such texts in Python with matplotlib?