热线电话:13121318867

登录
2019-03-04 阅读量: 1013
python如何使用用户定义的分段颜色绘制圆环图(1)

代码:

要在Excel工作表上使用用户定义的分段颜色绘制饼图,请使用add_series()带有图表对象的points关键字参数的方法。

# import xlsxwriter module 

import xlsxwriter

# Workbook() takes one, non-optional, argument   

# which is the filename that we want to create. 

workbook = xlsxwriter.Workbook('chart_doughnut2.xlsx')

# The workbook object is then used to add new   

# worksheet via the add_worksheet() method.  

worksheet = workbook.add_worksheet()

# Create a new Format object to formats cells 

# in worksheets using add_format() method . 

# here we create bold format object . 

bold = workbook.add_format({'bold': 1})

# Add the worksheet data that the charts will refer to.

headings = ['Category', 'Values']

data = [

['Glazed', 'Chocolate', 'Cream'],

[50, 35, 15],

]

1.2291
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子