|
May
07
|
|
|
Categories: Python
| Tags: ChartDirector, Python
| 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")
From 迷途知返, post PyChartDirector中文教程[5]:3D饼图
RELATED POSTS:
Leave a comment
| Trackback
