【发布时间】:2018-05-30 10:17:35
【问题描述】:
我希望能够将每个百分比值定位在距中心不同距离的位置,但 pctdistance 需要是单个值。
就我而言,pctdistance 应该是一个包含生成距离(由范围生成)的列表。
import matplotlib.pyplot as plt
fig =plt.figure(figsize = (10,10))
ax11 = fig.add_subplot(111)
# Data to plot
labels = 'Python', 'C++', 'Ruby', 'Java'
sizes = [215, 130, 245, 2000]
colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue']
explode = (0.1, 0, 0, 0) # explode 1st slice
# Plot
w,l,p = ax11.pie(sizes, labels=labels, colors=colors,
autopct='%1.1f%%', startangle=140, pctdistance=0.8, radius = 0.5)
[t.set_rotation(0) for t in p]
[t.set_fontsize(50) for t in p]
plt.axis('equal')
plt.show()
【问题讨论】:
标签: python matplotlib pie-chart