Python 官方文档:入门教程 => 点击学习
目录Pyecharts饼图位置调整不调整可能会显示成这样调整后的效果是这样利用Pyecharts 制作饼图Pyecharts饼图位置调整 如果要把 pyecharts 里的饼图嵌入其
如果要把 pyecharts 里的饼图嵌入其他页面,有的时候需要调整饼图的位置。
关键代码在于:
center=["40%", "60%"]
def pie_base_proc(p_dict, p_list) -> Pie:
c = (
Pie(init_opts=opts.InitOpts(width=p_dict['width'],height=p_dict['height']))
.add("", p_list,center=["40%", "60%"])
.set_global_opts(title_opts=opts.TitleOpts(title=p_dict['title']),
legend_opts=opts.LegendOpts(orient=p_dict['orient'], pos_left=p_dict['pos_left'], pos_top=p_dict['pos_top']))
.set_series_opts(label_opts=opts.LabelOpts(fORMatter="{b}", position='inside'))
)
return c
def lx_data_Pie(m_dict):
p_dict = {'title':m_dict['title'], 'width':'300px', 'height': '300px'}
# horizontal vertical
p_dict['orient'] ="horizontal"
p_dict['pos_left'] = "0%"
p_dict['pos_top'] = "5%"
m_data = m_dict['m_data']
p_list = [list(z) for z in zip(m_data[0], m_data[1])]
return pie_base_proc(p_dict,p_list)
from pyecharts import options as opts
from pyecharts.charts import Pie
from random import randint
def pie_base() -> Pie:
c = (
Pie()
.add("", [list(z) for z in zip(['宝马','法拉利','奔驰','奥迪','大众','丰田','特斯拉'],
[randint(1, 20) for _ in range(7)])])
.set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例"))
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
)
return c
pie_base().render('G:/pythonWorkSpace/MatplotlibNumpypandas/pie_pyecharts.html')
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Pyecharts中的饼图位置调整方式
本文链接: https://www.lsjlt.com/news/120874.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0