import pandas as pd
from bokeh.plotting import figure, show, output_file
from bokeh.palettes import brewer,d3
# bokeh.charts这个包以后会停止使用,具体时间不确定。
from bokeh.charts import Donut
# 数据源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'))
# 原文http://stackmirror.cn/page/rhtwz1sla71z
xdata = data['age']
ydata = data['population']
ydata.index =xdata
# 颜色代码https://bokeh.pydata.org/en/latest/docs/reference/palettes.html
colors = brewer["Accent"][len(data['age'])]
pie_chart = Donut(ydata,label=ydata.name)
show(pie_chart)
Pie Chart(bokeh)
最新推荐文章于 2024-07-06 23:21:33 发布