matplotlib设置饼图牵引线的粗细
在matplotlib中设置饼图的牵引线粗细,可以使用参数“linewidths”。例如,如果要将牵引线的粗细设置为2像素,则可以使用以下代码:
import matplotlib.pyplot as plt
labels = ['A', 'B', 'C', 'D']
sizes = [15, 30, 45, 10]
fig, ax = plt.subplots()
ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90, counterclock=False,
wedgeprops={'linewidth': 2, 'edgecolor': 'white'}, textprops={'fontsize': 14})
plt.show()
在上面的代码中,我们通过“wedgeprops”参数设置牵引线的粗细为2像素,并将其边缘颜色设置为白色。通过这种方式,我们可以轻松地调整饼图中的牵引线粗细和颜色,以满足我们的需求。
原文地址: http://www.cveoy.top/t/topic/htIM 著作权归作者所有。请勿转载和采集!