from pyecharts.charts import Pie
import pandas as pd
from pyecharts import options as opts
# pd.read_csv() 将csv文件 以 二维的形式读入 且 第一行 默认 不算入
vote = pd.read_csv("vote_result.csv")
print(vote) # 二维形式输出
print(vote.values)
print(vote.values.tolist());
c = (
Pie()
.add(
"",
vote.values.tolist(),
radius=["35%", "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": 15, "align": "center"},
"abg": {
"backgroundColor": "#e3e3e3",
"width": "100%",
"align": "right",
"height": 15,
"borderRadius": [4, 4, 0, 0],
},
"hr": {
"borderColor": "#aaa",
"width": "100%",
"borderWidth": 0.5,
"height": 0,
},
"b": {"fontSize": 16, "lineHeight": 44},
"per": {
"color": "#eee",
"backgroundColor": "#334455",
"padding": [2, 4],
"borderRadius": 2,
},
},
),
)
.set_global_opts(title_opts=opts.TitleOpts(title="Pie-rate"))
.render("pie_circle.html")
)
Pie——环形图
最新推荐文章于 2022-12-24 17:10:58 发布