Categories: Python | Tags: , | Views: 2,895

 

前面我们画了一个非常简单的饼状图, 接下来,我们来扩展一下这个饼状图吧,

先看看我们扩展的这个3D饼图:

 

 

这个例子对先一个例子进行了扩展:

用BaseChart.addTitle添加了标题

用PieChart.set3D画3D图

用PieChart.setExplode展开其中的一块区域

源代码:

#!/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
c.setPieSize(180, 140, 100)
 
# Add a title to the pie chart, 添加标题
c.addTitle("Project Cost Breakdown")
 
# Draw the pie in 3D, 3D模式
c.set3D()
 
# Set the pie data and the pie labels
c.setData(data, labels)
 
# Explode the 1st sector (index = 0)
c.setExplode(0)  #展开第一块区域
 
# Output the chart
c.makeChart("threedpie.png")

RELATED POSTS:

  1. PyChartDirector中文教程[2]:Hello, world!
  2. PyChartDirector中文教程[3]:嵌入网页
  3. PyChartDirector中文教程[4]:简单的饼状图
  4. PyChartDirector中文教程[6]:多深度饼图
  5. PyChartDirector中文教程[7]:饼图的标签
  6. PyChartDirector中文教程[8]:饼图的图例

2 trackbacks

  1. TOM Trackback | 2010/07/16
  2. 5-speed Trackback | 2010/08/30
;) :| :x :twisted: :roll: :oops: :o :mrgreen: :lol: :idea: :evil: :cry: :arrow: :P :D :?: :? :) :( :!: 8O 8)

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