Python中如何使用pyecharts进行数据可视化?

2026-06-10 20:341阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计444个文字,预计阅读时间需要2分钟。

Python中如何使用pyecharts进行数据可视化?

文档:https://pyecharts.org/

安装:使用pip安装pyecharts:pip install pyecharts

示例:pythonfrom pyecharts.charts import Barfrom pyecharts import options as opts

bar=Bar()bar.add_xaxis([类别1, 类别2, 类别3])bar.add_yaxis(系列1, [10, 20, 30])bar.set_global_opts(title_opts=opts.TitleOpts(title=柱状图示例))bar.render(柱状图示例.)

  文档:​​pyecharts.org/​​

安装:

  

pip install pyecharts

示例:

from pyecharts.charts import Bar
from pyecharts import options as opts

# V1 版本开始支持链式调用
# 你所看到的格式其实是 `black` 格式化以后的效果
# 可以执行 `pip install black` 下载使用
bar = (
Bar()
.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
# 或者直接使用字典参数
# .set_global_opts(title_opts={"text": "主标题", "subtext": "副标题"})
)
bar.render()

# 不习惯链式调用的开发者依旧可以单独调用方法
bar = Bar()
bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
bar.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
bar.render()

常见问题:

  1.使用snapshot_selenium渲染图片的时候,发生错误

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to

  解决:

    原因是Chrome浏览器需要配置chromedriver

    1)打开浏览器输入chrome://version/ 查看chrome版本,

Python中如何使用pyecharts进行数据可视化?

    2)访问网址:​​chromedriver.storage.googleapis.com/index.html​​ 选择合适版本的driver, 下载即可

    3)下载完成之后, 解压文件到python的根目录下即可

本文共计444个文字,预计阅读时间需要2分钟。

Python中如何使用pyecharts进行数据可视化?

文档:https://pyecharts.org/

安装:使用pip安装pyecharts:pip install pyecharts

示例:pythonfrom pyecharts.charts import Barfrom pyecharts import options as opts

bar=Bar()bar.add_xaxis([类别1, 类别2, 类别3])bar.add_yaxis(系列1, [10, 20, 30])bar.set_global_opts(title_opts=opts.TitleOpts(title=柱状图示例))bar.render(柱状图示例.)

  文档:​​pyecharts.org/​​

安装:

  

pip install pyecharts

示例:

from pyecharts.charts import Bar
from pyecharts import options as opts

# V1 版本开始支持链式调用
# 你所看到的格式其实是 `black` 格式化以后的效果
# 可以执行 `pip install black` 下载使用
bar = (
Bar()
.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
# 或者直接使用字典参数
# .set_global_opts(title_opts={"text": "主标题", "subtext": "副标题"})
)
bar.render()

# 不习惯链式调用的开发者依旧可以单独调用方法
bar = Bar()
bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
bar.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
bar.render()

常见问题:

  1.使用snapshot_selenium渲染图片的时候,发生错误

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to

  解决:

    原因是Chrome浏览器需要配置chromedriver

    1)打开浏览器输入chrome://version/ 查看chrome版本,

Python中如何使用pyecharts进行数据可视化?

    2)访问网址:​​chromedriver.storage.googleapis.com/index.html​​ 选择合适版本的driver, 下载即可

    3)下载完成之后, 解压文件到python的根目录下即可