我最近只接受了使用import
import turle
函数绘制饼图的任务。我有图表标题,细分标签和所需的百分比,但我不确定是否正在绘制它。
这样做最简单,最简单的程序是什么?
我在考虑首先绘制线段然后添加标签。任何建议将不胜感激。
答案 0 :(得分:0)
You should do it step by step :
- Circle
- Then for each segments
go to center
trace radius (you should compute the coordinates of points on circle with simple polar algebra)
add color
add label
是将百分比/标签存储为列表似乎是一件好事。
编辑: 如果百分比在列表中,则可以使用语法进行迭代 对于列表中的perc
然后你可以通过乘以2pi *百分比来计算角度θ
要追踪半径[OM],需要M(r,theta)的笛卡尔坐标,即(rcos(theta); rsin(theta))