我在显示图像的宽度和高度时遇到问题。它的某些部分无法显示在png文件中。(特别是右侧,一些文本无法显示)如何解决?
下面是我的代码。
plt.figure(figsize=(10,9))
ax = subplot_kw=dict(aspect="equal")
my_circle = plt.Circle((0, 0), 0.7, color='white')
d = plt.pie(symptoms['percentage'],
autopct='%1.1f%%',
pctdistance=0.85,
labeldistance=1.1,
textprops = {'fontsize':10.5})
plt.axis('equal')
plt.gca().add_artist(my_circle)
plt.text(0,
0,
"Symptoms of Coronavirus",
horizontalalignment='center',
verticalalignment='center',
size=16,
)
plt.legend(symptoms['symptom'],loc='right',bbox_to_anchor=[1.2, 0.5])
plt.savefig('images/image2.png')
plt.savefig('images/image2.pdf')
plt.show()
答案 0 :(得分:0)
我通过编写下面显示的代码解决了这个问题。
.....
plt.tight_layout()
plt.show()