|
May
04
|
|
|
Categories: Default
| Tags: ChartDirector, Python
| Views: 2,072
|
先来看看我们要画的这个最简单的饼状图吧:
这个例子展示了画饼状图的基本步骤:
用PieChart创建一个pie chart对象
用setPieSize指定中心和半径
为饼状图指定数据
用makeChart保存图像
我们先看一下源代码:
#!/usr/bin/python from pychartdir import * # The data for the pie chart data = [25, 18, 15, 12, 8, 30, 35] # The labels for the pie chart labels = ["Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities", "Production"] # Create a PieChart object of size 360 x 300 pixels c = PieChart(360, 300) # Set the center of the pie at (180, 140) and the radius to 100 pixels, # 圆心(180,140) 半径:100px c.setPieSize(180, 140, 100) # Set the pie data and the pie labels # 指定数据和标签 c.setData(data, labels) # Output the chart c.makeChart("simplepie.png")
简单吧!
From 迷途知返, post PyChartDirector中文教程[4]:简单的饼状图
RELATED POSTS:
Leave a comment
| Trackback


