pyecharts产生背景

Echarts是由百度开源的数据可视化,凭借良好的交互性和精巧的图表设计,得到众多开发者的认可,而python很适合用于数据处理,数据分析遇到数据可视化时pyecharts就产生了。

官网链接:https://pyecharts.org/#/

画廊pyecharts-gallery

pyecharts支持的图表众多,官方提供了画廊用于参考。

画廊链接:https://gallery.pyecharts.org/#/

一、pyecharts模块安装

使用pip命令快速安装:

pip install pyecharts

此处省略,跟前面的文章安装第三方包的操作一样。

Python pyecharts模块安装与入门教程

二、pyecharts入门

1、基础折线图

①导包Line

from pyecharts.charts import Line

②得到折线图对象

line = Line()

③添加x轴数据

line.add_xaxis(["中国","美国","英国"])

④添加y轴数据

line.add_yaxis("GDP",[30,20,10])

⑤生成图表

line.render()

运行后出现一个html文件,打开html文件会出现可视化图表。

Python pyecharts模块安装与入门教程

Python pyecharts模块安装与入门教程

2、pyecharts配置选项

全局配置选项

可通过set_global_opts方法配置

更多配置选项可前往官网参考。

例:

from pyecharts.options import TitleOpts,LegendOpts,ToolboxOpts,VisualMapOpts
line.set_global_opts(
    title_opts=TitleOpts("GDP展示","center","1%"),
    legend_opts=LegendOpts(True),
    toolbox_opts=ToolboxOpts(True),
    visualmap_opts=VisualMapOpts(True)
)

Python pyecharts模块安装与入门教程

原文地址:https://blog.csdn.net/Tir_zhang/article/details/126739936

相关文章:

  • 2021-12-12
  • 2021-11-20
  • 2021-12-17
  • 2021-07-13
  • 2021-07-01
  • 2022-02-18
  • 2021-10-17
猜你喜欢
  • 2023-03-12
  • 2021-10-16
  • 2021-08-26
  • 2021-05-23
  • 2022-12-23
  • 2021-11-22
相关资源
相似解决方案