I wonder below the picture, how could I label texts on different phases of the lines?
For convenience, I provide an easy case as below:Please tell me, how to mark the two sections with f(t)=2
and f(t)=t
? I expect the label is automatically attached to the line?
import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.where(t>=2,t,2)
t=np.arange(-4, 6, 0.1)
plt.axis([-4,6,1,4])
plt.plot(t,f(t))]
plt.text(-3,3.5,'How to mark the two sections with\n f(t)=2 and f(t)=t?\nI expect the label automatically \natached to the line')
plt.show()