Pie Chart(nvd3)

import pandas as pd
# https://bl.ocks.org/mbostock/3887235原文
data = pd.DataFrame([['<5',2704659],['5-13',4499890],['14-17',2159981],
                     ['18-24',3853788],['25-44',14106543],['45-64',8819342],['≥65',612463]],columns=('age','population'))
from nvd3 import pieChart
type = "pieChart"
chart = pieChart(name=type, color_category='category20c', height=600, width=600)
chart.set_containerheader("\n\n" + type + "\n\n")#这里是可以写html语句的
extra_serie = {"tooltip": {"y_start": "", "y_end": " men"}}
xdata = data['age']
ydata = data['population'].astype(str)
chart.add_serie(y=ydata, x=xdata, extra=extra_serie)
# 生成网页块码
chart.buildcontent()
# 显示网页块码
print(chart.htmlcontent)
# 生成html源码
chart.buildhtml()
# 保存本地
output_file = open('test_pieChart.html', 'w')
output_file.write(chart.htmlcontent)
output_file.close()


This pie chart is constructed from a CSV file storing the populations of various age groups.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值