pyecharts

2022-03-04  本文已影响0人  minlover

1、生成的是html,那么怎么输出图片。

首先安装snapshot:

pip install pyecharts-snapshot

pip install snapshot_selenium

安装ChromeDriver

下载地址:https://registry.npmmirror.com/binary.html?path=chromedriver/

(选跟浏览器一样的版本的)

浏览器右上角三个点-->帮助-->关于google chrome,能看到版本

将ChromeDriver.exe放到项目文件所在文件夹即可。

然后程序中在render之后加一步:(可以png,pdf,gif等)

from pyecharts.render import make_snapshot

from snapshot_selenium import snapshot

make_snapshot(snapshot, geo.render("geo_cmu.html"),"geo_cmu.png")

2、修改标题、图例等自定义文字的字号、粗细等

参考链接:https://www.freesion.com/article/96561030035/

legend_opts=opts.LegendOpts(type_="plain", pos_right="10%",pos_bottom = "20%",orient="vertical",is_show=True,textstyle_opts=opts.TextStyleOpts(font_size=18)),

这里设置了图例类型是普通plain,距离右边和下面的位置,排列是垂直排列,显示图例,字号为18

修改标题的位置、粗细、字号:

geo.set_global_opts(title_opts=opts.TitleOpts(title="位置已知用户和未知用户的位置分布情况-GeoText数据集", pos_right="center",pos_bottom = "5%",title_textstyle_opts = opts.TextStyleOpts(font_weight="normal",font_size=26)), 

上一篇 下一篇

猜你喜欢

热点阅读