matplotlib pie chart move autotext

Solutions on MaxInterview for matplotlib pie chart move autotext by the best coders in the world

showing results for - "matplotlib pie chart move autotext"
Vincent
05 Jun 2017
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
similar questions
queries leading to this page
matplotlib pie chart move autotext