Я строю 4 круговых диаграммы на одной фигуре, используя функцию. Тем не менее, я понял, что в зависимости от того, как долго имена клавиш находятся в тексте, круговые диаграммы перемещаются. Как я могу это исправить и сохранить их похожими на рисунок 1?
Вот моя функция:
def create_pie_chart(title, pie_dict, top_design, pyplot, nbr, cord1, cord2, loc_nbr):
#pyplot.figure()
counts = collections.Counter(pie_dict) # color for pie chart
pyplot.subplot(2, 2, nbr)
pyplot.pie([float(v) for v in counts.values()], labels=[k for k in counts],
autopct='%1.1f%%', radius=9, shadow=True, labeldistance=1.05, startangle=125,
pctdistance=0.7, center=(cord1, cord2))
centre_circle = pyplot.Circle((0,0), 2, fc='white')
pyplot.gca().set_title(title+top_design)
fig = pyplot.gcf()
fig.gca().add_artist(centre_circle)
#pyplot.suptitle(title+top_design)
pyplot.axis('equal')
pyplot.legend(labels=counts, loc='center right', fontsize = 'x-small', bbox_to_anchor=(0.2, 0.2, 1, 1), facecolor='grey')
pyplot.tight_layout()
pyplot.title(title+top_design, fontsize = 'medium')
Я называю это так:
create_pie_chart("second pie chart\n ", dict_2, "two", pyplot, 2, 0, 0, 1)
Я хочу, чтобы это выглядело так:

Тем не менее, когда размеры ключевых слов становятся больше, они выглядят так:
.