Categories: Default | Tags: , | 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")

 

简单吧!

 

RELATED POSTS:

  1. PyChartDirector中文教程[2]:Hello, world!
  2. PyChartDirector中文教程[3]:嵌入网页
  3. PyChartDirector中文教程[5]:3D饼图
  4. PyChartDirector中文教程[6]:多深度饼图
  5. PyChartDirector中文教程[7]:饼图的标签
  6. PyChartDirector中文教程[8]:饼图的图例
No comments yet.
;) :| :x :twisted: :roll: :oops: :o :mrgreen: :lol: :idea: :evil: :cry: :arrow: :P :D :?: :? :) :( :!: 8O 8)

你可以使用@somebody:开头, 来邮件通知somebody你回复了他的留言(用户名区分大小写).