from pyecharts import options as opts from pyecharts.charts import Page, Pie wd = ['教授','副教授','讲师','助教','其他'] num = [20,30,10,12,8] c = Pie() c.add("",[list(z) for z in zip(wd, num)],radius=["40%", "55%"], label_opts=opts.LabelOpts(position="outside", formatter="{a|{a}}{abg|}\n{hr|}\n{b|{b}:}{c} {per|{d}%} ", background_color="#eee",border_color="#aaa", border_width=1,border_radius=4, rich={"a": {"color": "#999", "lineHeight": 22, "align": "center"},"abg": {"backgroundColor": "#e3e3e3","width": "100%", "align": "right", "height": 22,"borderRadius": [4, 4, 0, 0],}, "hr": {"borderColor": "#aaa", "width": "100%", "borderWidth": 0.5, "height": 0,}, "b": {"fontSize": 16, "lineHeight": 33},"per": {"color": "#eee", "backgroundColor": "#334455", "padding": [2, 4],"borderRadius": 2,} } )) c.set_global_opts(title_opts=opts.TitleOpts(title="Pie-富文本示例")) c.render_notebook()
时间: 2023-07-12 11:57:20 浏览: 150
pyecharts 地理图表之地理坐标系.pdf
这段代码是用 Python 的 pyecharts 库画一个富文本饼图,展示教师职称的分布情况。其中 wd 列表是教师职称,num 列表是对应职称的人数。通过 c.add() 方法添加数据和设置标签样式,最后调用 c.render_notebook() 方法在 Jupyter Notebook 中展示图表。
阅读全文