1for patch, txt in zip(patches, autotexts):
2 # the angle at which the text is located
3 ang = (patch.theta2 + patch.theta1) / 2.
4 # new coordinates of the text, 0.7 is the distance from the center
5 x = patch.r * 0.7 * np.cos(ang*np.pi/180)
6 y = patch.r * 0.7 * np.sin(ang*np.pi/180)
7 # if patch is narrow enough, move text to new coordinates
8 if (patch.theta2 - patch.theta1) < 10.:
9 txt.set_position((x, y))
10