I have a pie chart showing the percentage of product sales from total revenue. The product names are too big, so they are abbreviated around the diagram, but in the legend the names should be full. Basically I just need to replace the labels in the legend. However, when creating a pie chart, I specify a list of labels from where the program should take them and the subsequent change of labels in the legend does not change anything. data_names - Full names data_names 2 - Abbreviated names The labels=data_names command in plt.legend does not work.
ax.pie(data_values, labels=data_names2, colors=colors, radius=5, center=(0, 0),
wedgeprops={"linewidth": 0.4, "edgecolor": "white"}, frame=True, rotatelabels=True)
plt.legend(
loc='best', bbox_to_anchor=(1, 0.92),labels=data_names)
CodePudding user response:
I found this link that might be helpful.
Hope that helps.
Regards.