python 实现绘制饼状图 源代码
时间: 2024-01-05 11:44:49 浏览: 75
饼状图 源码
当然可以,这是一份Python实现绘制饼状图的示例代码:
```python
import matplotlib.pyplot as plt
# 绘制图形
labels = ['A', 'B', 'C', 'D', 'E']
size = [15, 20, 25, 30, 10]
explode = (0, 0, 0, 0.1, 0)
colors = ['#FF9999', '#FFE888', '#FFDDDD', '#F0E68C', '#B19CD9']
plt.pie(size, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=90)
# 样式设置
plt.axis('equal')
plt.title('Pie Chart Example')
# 绘制图形
plt.show()
```
希望对你有所帮助!
阅读全文