Python icon pyecharts

line chart

insert image description here

# 导包
from pyecharts.charts import Line
from pyecharts.options import TitleOpts,LegendOpts,ToolboxOpts,VisualMapOpts

# 创建一个折线图对象
line = Line()
# 给折线图添加X轴数据
line.add_xaxis(["中国",'日本',"美国"])
# 给折线图 添加Y轴数据  ctrp + P  可以显示参数情况
line.add_yaxis("GDP",[220, 120, 300])
# Y轴可以设置多个系列
# 设置全局配置项 set_global_opts

line.set_global_opts(
    # 标题
    title_opts=TitleOpts(title="GDP展示",pos_left="center",pos_bottom="1%"),
    legend_opts=LegendOpts(is_show=True),
    toolbox_opts=ToolboxOpts(is_show=True),
    visualmap_opts=VisualMapOpts(is_show=True),
)

# 通过render方法,渲染生成图标
line.render()


insert image description here

map

Data style:
[
("Province",Val), ("Province",Val), ("Province",Val),
]
insert image description here

insert image description here
is_piecewise=False
insert image description here

# 导包
from pyecharts.charts import  Map
from pyecharts.options import VisualMapOpts
# 创建Map对象
my_map = Map()

# 地图数据  列表里面一堆元组
my_data = [
    ("上海市",299),
    ("江苏省",500)
]
"""
my_data = [
    ["上海市",299],
    ["江苏省",500]
]
"""
my_map.add("测试地图",data_pair=my_data)
# 全局配置
my_map.set_global_opts(
    visualmap_opts=VisualMapOpts(
        is_show=True,
        is_piecewise=True,
        pieces=[
            {
    
    "min":1,"max":100,"label":"1-100","color":"#CCFFFF"},
            {
    
    "min":101,"max":200,"label":"101-200","color":"#DDFFFF"},
            {
    
    "min":201,"max":300,"label":"201-300","color":"#AAFFFF"},
            {
    
    "min":301,"max":500,"label":"301-3500","color":"#345FFF"}
        ]

    )
)
# 地图渲染  生成对应的xxx.html  文件
my_map.render("xxx.html")  

histogram

# 导入柱状图
from pyecharts.charts import Bar
from pyecharts.options import LabelOpts

# 创建Bar 对象
bar = Bar()


# 为bar 添加x轴数据
bar.add_xaxis(["苏州","南京","徐州"])

# 为Bar添加Y轴数据

bar.add_yaxis("房价",[30000,45000,20000])
## xy轴反转,要把laber位置调整一下
## bar.add_yaxis("房价",[30000,45000,20000],label_opts=LabelOpts(position="right"))
#  反转xy转
bar.reversal_axis()
#渲染 Bar
bar.render("状态图.html")

timeline

insert image description here
insert image description here

# 导入柱状图
from pyecharts.charts import Bar,Timeline
from pyecharts.options import LabelOpts
from pyecharts.globals import ThemeType
# 创建Bar 对象
bar1 = Bar()
# 为bar 添加x轴数据
bar1.add_xaxis(["苏州","南京","徐州"])
# 为Bar添加Y轴数据
bar1.add_yaxis("房价",[30000,45000,20000],label_opts=LabelOpts(position="right"))
bar1.reversal_axis()

# 创建Bar 对象
bar2 = Bar()
#   给Bar  设置了主题
# bar2 = Bar(init_opts=InitOpts(theme=ThemeType.LIGHT))
# 为bar 添加x轴数据
bar2.add_xaxis(["苏州","南京","徐州"])
# 为Bar添加Y轴数据
bar2.add_yaxis("房价",[2000,45000,2000],label_opts=LabelOpts(position="right"))
bar2.reversal_axis()

#  创建时间线,以及主题
timeLine = Timeline(
	{
    
    "theme":ThemeType.LIGHT	}
)	
#  设置自动播放
timeLine.add_schema(
	play_interval = 1000, 		# 自动播放的时间间隔,单位为毫秒
	is_timeLine_show = True, 	# 是否在自动播放的时候,显示时间线
	is_auto_play = True, 		# 是否自动播放
	is_loop_play = True			# 是否循环自动播放
)
timeLine.add(bar1,"2020年")
timeLine.add(bar2,"2023年")
#渲染 Bar
timeLine.render("时间线柱状图.html")

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/u013400314/article/details/131228966