实现效果
创建名为: a.py的py文件,并把以下代码写入文件
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType
city_values = [
["四川",1500],["广西",200],["广州",1700],["云南",500],["北京",2000]
]
line_value = [
["四川", "广西"], ["四川", "广州"], ["四川", "云南"], ["四川", "北京"]
]
c = (
Geo()
.add_schema(maptype="china")
.add(
series_name="前往地区",
data_pair=city_values,
type_=ChartType.EFFECT_SCATTER,
color="#43748b",
)
.add(
series_name="迁徙路线",
data_pair=line_value,
type_=ChartType.LINES,
effect_opts=opts.EffectOpts(
symbol=SymbolType.TRIANGLE, symbol_size=6, color="#63d4e6"
),
linestyle_opts=opts.LineStyleOpts(curve=0.3, color="#63d4e6"),
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(title_opts=opts.TitleOpts(title="数据为虚构"))
)
c.render("模拟迁徙地图.html")
运行a.py文件,会在a.py的目录下生成模拟迁徙地图.html的html文件,打开即为2.的实现效果
原文:https://www.cnblogs.com/Coder-Photographer/p/13558771.html