通过Python pyecharts输出保存图片代码实例
作者:-零 时间:2021-09-14 22:26:11
安装pyecharts:pip install pyecharts
安装snapshot-selenium:pip install snapshot-selenium
安装ChromeDriver:下载地址
注意:下载和电脑上的谷歌浏览器版本相同或者相近的版本,将ChromeDriver.exe放到项目文件所在文件夹即可。
代码示例
from pyecharts.charts import Bar
from pyecharts import options as opts
# 导入输出图片工具
from pyecharts.render import make_snapshot
# 使用snapshot-selenium 渲染图片
from snapshot_selenium import snapshot
# 创建一个柱状图Bar实例
bar = (
Bar()
# 添加X轴数据
.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
# 添加Y轴数据,系列的名称
.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
.add_yaxis("商家B", [8, 15, 60, 20, 25, 30])
# 添加标题
.set_global_opts(title_opts=opts.TitleOpts(title="主标题: 双十一销量", subtitle="副标题:服饰类"))
)
# 输出保存为图片
make_snapshot(snapshot, bar.render(), "Options配置项_自定义样式_保存图片.png")
来源:https://www.cnblogs.com/-wenli/p/14024078.html
标签:Python,pyecharts,输出,图片
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
opencv python Canny边缘提取实现过程解析
2023-08-20 19:43:18
![](https://img.aspxhome.com/file/2023/4/81834_0s.png)
聊聊Python对CSV文件的读取与写入问题
2023-09-26 09:42:29
![](https://img.aspxhome.com/file/2023/7/65527_0s.png)
Python科学计算环境推荐——Anaconda
2022-12-17 15:07:30
![](https://img.aspxhome.com/file/2023/0/84990_0s.jpg)
Python数据可视化实现正态分布(高斯分布)
2022-10-28 03:31:29
![](https://img.aspxhome.com/file/2023/0/87780_0s.jpg)
opencv+python实现均值滤波
2023-10-21 15:00:58
![](https://img.aspxhome.com/file/2023/2/82532_0s.jpg)
python中判断文件结束符的具体方法
2021-09-28 13:31:53
Python使用matplotlib绘图无法显示中文问题的解决方法
2023-07-30 22:16:30
![](https://img.aspxhome.com/file/2023/2/61462_0s.png)
解析:轻松掌握 字符串文字字符集和校对
2008-12-17 17:07:00
利用PHP自动生成印有用户信息的名片
2023-09-10 22:30:56
![](https://img.aspxhome.com/file/2023/3/55483_0s.png)
创建数据表/创建列的一些asp函数
2008-06-24 12:21:00
深度解读Python如何实现dbscan算法
2023-12-22 01:31:50
![](https://img.aspxhome.com/file/2023/2/68892_0s.png)
python SVD压缩图像的实现代码
2023-04-18 18:23:30
![](https://img.aspxhome.com/file/2023/6/86496_0s.jpg)
sql server 锁表语句分享
2012-02-12 15:49:20
妄想or未来?界面的虚拟现实化
2010-03-01 12:53:00
![](https://img.aspxhome.com/file/UploadPic/20103/1/1002-gui-virtual-01-22s.jpg)
Mango Cache缓存管理库TinyLFU源码解析
2023-09-02 12:27:51
python检测空间储存剩余大小和指定文件夹内存占用的实例
2022-10-30 06:52:51
Python 剪绳子的多种思路实现(动态规划和贪心)
2021-07-03 18:43:41
pandas获取groupby分组里最大值所在的行方法
2021-08-14 21:39:14
JAVA/JSP学习系列之一
2023-06-19 16:44:14
Python基于pillow库实现生成图片水印
2021-08-01 10:45:38