python - How to make pie chart with optimized code?
问题描述
What is the shortest and most optimal code for make pie chart? I want to make a pie chart using python. I tried to use the best library but most of them were long. Anyone have a shortcut?
解决方案
import matplotlib.pyplot as plt
percent = [ x, y, z]
colour = [blue, green, red]
label = [name1, name2, name3]
plt.pie(percent , labels=label ,colors=colour)
plt.show()
#The sum of the values of x,y,z must be 100 for 100%
推荐阅读
- python - 在数据框行的文本标签上创建成对相似度矩阵
- php - 为了保留彩色输出,我必须将 lynis 导出为什么格式?
- unity3d - MRTK“控制台”在构建时出现在一只眼睛中
- javascript - 如何用逗号而不是点对价格进行四舍五入?
- django - Django 保持签名两周或直到浏览器关闭
- reactjs - 如何在 React JS 中更改错误警报的位置
- here-api - 为什么使用公共交通的 HERE Routing API 中的参数 TransitRadius 不会更改响应
- python - 在models.py中添加外键时遇到错误
- python - 我怎样才能为每个组合总结一个熊猫数据框?
- r - 分隔r中的两个单词