当前位置:网站首页>04 pyechars 地理图表(示例代码+效果图)
04 pyechars 地理图表(示例代码+效果图)
2022-07-28 11:42:00 【懒笑翻】
目录
1 GEO-地理坐标系
import random
from pyecharts.charts import Geo
from pyecharts.faker import Faker
province = [
'广东',
'湖北',
'湖南',
'四川',
'重庆',
'黑龙江',
'浙江',
'山西',
'河北',
'安徽',
'河南',
'山东',
'西藏']
data = [(i, random.randint(10, 100)) for i in province]
geo = (
Geo()
.add_schema(maptype="china")
.add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
# .add("", data)
)
print([list(z) for z in zip(Faker.provinces, Faker.values())])
geo.render("geo.html")
2 MAP-地图
import random
from pyecharts.charts import Map
province = [
'广东',
'湖北',
'湖南',
'四川',
'重庆',
'黑龙江',
'浙江',
'山西',
'河北',
'安徽',
'河南',
'山东',
'西藏']
data = [(i, random.randint(10, 100)) for i in province]
map_ = (
Map()
.add("", data, 'china')
)
map_.render("map.html")
3 BMAP-百度地图
import random
from pyecharts.charts import BMap
province = [
'广东',
'湖北',
'湖南',
'四川',
'重庆',
'黑龙江',
'浙江',
'山西',
'河北',
'安徽',
'河南',
'山东',
'西藏']
data = [(i, random.randint(50, 150)) for i in province]
bmap = (
BMap()
.add_schema(baidu_ak="输入你的百度AK", center=[120.13066322374, 30.240018034923])
.add("", data)
)
bmap.render("bmap.html")1 Geo()
class Geo(
# 初始化配置项,参考 `global_options.InitOpts`
init_opts: opts.InitOpts = opts.InitOpts()
# 是否忽略不存在的坐标,默认值为 False,即不忽略
is_ignore_nonexistent_coord: bool = False
)
2 def add_schema
def add_schema(
# 地图类型,具体参考 pyecharts.datasets.map_filenames.json 文件
maptype: str = "china",
# 是否开启鼠标缩放和平移漫游。
is_roam: bool = True,
# 当前视角的缩放比例。默认为 1
zoom: Optional[Numeric] = None,
# 当前视角的中心点,用经纬度表示。例如:center: [115.97, 29.71]
center: Optional[Sequence] = None,
# 参数用于 scale 地图的长宽比。
aspect_scale: types.Numeric = 0.75,
# 二维数组,定义定位的左上角以及右下角分别所对应的经纬度。
bounding_coords: types.Optional[types.Sequence[types.Numeric]] = None,
# 最小的缩放值。
min_scale_limit: types.Optional[types.Numeric] = None,
# 最大的缩放值。
max_scale_limit: types.Optional[types.Numeric] = None,
# 默认是 'name',针对 GeoJSON 要素的自定义属性名称,作为主键用于关联数据点和 GeoJSON 地理要素。
name_property: str = "name",
# 选中模式,表示是否支持多个选中,默认关闭,支持布尔值和字符串。
# 字符串取值可选'single'表示单选,或者'multiple'表示多选。
selected_mode: types.Union[bool, str] = False,
# pyecharts 暂时没有提供 left/top/right/bottom 的配置
# layoutCenter 和 layoutSize 提供了除了 left/right/top/bottom/width/height 之外的布局手段。
# 在使用 left/right/top/bottom/width/height 的时候
# 可能很难在保持地图高宽比的情况下把地图放在某个盒形区域的正中间,并且保证不超出盒形的范围。
# 此时可以通过 layoutCenter 属性定义地图中心在屏幕中的位置,layoutSize 定义地图的大小。
# 如下示例
# layoutCenter: ['30%', '30%'],
# // 如果宽高比大于 1 则宽度为 100,如果小于 1 则高度为 100,保证了不超过 100x100 的区域
# layoutSize: 100
layout_center: types.Optional[types.Sequence[str]] = None,
# 地图的大小,见 layoutCenter。支持相对于屏幕宽高的百分比或者绝对的像素大小。
layout_size: types.Union[str, types.Numeric] = None,
# # 标签配置项,参考 `series_options.LabelOpts`
label_opts: Union[opts.LabelOpts, dict, None] = None,
# 地图区域的多边形 图形样式。
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] =None,
# 高亮状态下的多边形样式
emphasis_itemstyle_opts: Union[opts.ItemStyleOpts, dict,None] = None,
# 高亮状态下的标签样式。
emphasis_label_opts: Union[opts.LabelOpts, dict, None] =None,
):
3 def add()
def add(
# 系列名称,用于 tooltip 的显示,legend 的图例筛选。
series_name: str,
# 数据项 (坐标点名称,坐标点值)
data_pair: Sequence,
# Geo 图类型,有 scatter, effectScatter, heatmap, lines 4 种,建议使用
# from pyecharts.globals import GeoType
# GeoType.GeoType.EFFECT_SCATTER,GeoType.HEATMAP,GeoType.LINES
type_: str = "scatter",
# 是否选中图例
is_selected: bool = True,
# 标记图形形状
symbol: Optional[str] = None,
# 标记的大小
symbol_size: Numeric = 12,
# 每个点的大小,在地理坐标系(coordinateSystem: 'geo')上有效。
blur_size: types.Numeric = 20,
# 每个点模糊的大小,在地理坐标系(coordinateSystem: 'geo')上有效。
point_size: types.Numeric = 20,
# 系列 label 颜色
color: Optional[str] = None,
# 是否是多段线,在画 lines 图情况下
is_polyline: bool = False,
# 是否启用大规模线图的优化,在数据图形特别多的时候(>=5k)可以开启
is_large: bool = False,
# 特效尾迹的长度。取从 0 到 1 的值,数值越大尾迹越长。默认值 0.2
trail_length: Numeric = 0.2,
# 开启绘制优化的阈值。
large_threshold: Numeric = 2000,
# 配置该系列每一帧渲染的图形数
progressive: types.Numeric = 400,
# 启用渐进式渲染的图形数量阈值,在单个系列的图形数量超过该阈值时启用渐进式渲染。
progressive_threshold: types.Numeric = 3000,
# 标签配置项,参考 `series_options.LabelOpts`
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
# 涟漪特效配置项,参考 `series_options.EffectOpts`
effect_opts: Union[opts.EffectOpts, dict] = opts.EffectOpts(),
# 线样式配置项,参考 `series_options.LineStyleOpts`
linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
# 提示框组件配置项,参考 `series_options.TooltipOpts`
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
# 图元样式配置项,参考 `series_options.ItemStyleOpts`
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
# 这个配置相对非常复杂(参照地址: https://www.echartsjs.com/zh/option.html#series-custom.renderItem)
render_item: types.JsCode = None,
# 这个配置相对非常复杂(参照地址: https://www.echartsjs.com/zh/option.html#series-custom.encode)
encode: types.Union[types.JsCode, dict] = None,
)
边栏推荐
- Arduino Pro Mini atmega328p connect and light the first LED (at the same time, record the problem of burning failure stk500_recv)
- 金九银十 再不卷就来不及了
- IRBuilder
- 用arduino开发ESP8266 搭建开发环境
- 新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
- 恋爱男女十禁
- C for循环内定义int i变量出现的重定义问题
- 用C语言开发NES游戏(CC65)06、精灵
- Minimally invasive electrophysiology has passed the registration: a listed enterprise with annual revenue of 190million minimally invasive mass production
- Some API interfaces purchased by Yiwu hope to bring you some help
猜你喜欢

Hongjiu fruit passed the hearing: five month operating profit of 900million Ali and China agricultural reclamation are shareholders

MarkDown简明语法手册

卸载 Navicat:正版 MySQL 官方客户端,真香!
![[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou

Unity 安装 Device Simulator

Developing NES games with C language (cc65) 09, scrolling

洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东

Basic use of JSON server

设计一个线程池

数字经济时代的开源数据库创新 | 2022 开放原子全球开源峰会数据库分论坛圆满召开
随机推荐
How does musk lay off staff?
With the continuous waves of infringement, the U.S. patent and trademark office began to study the impact of NFT on copyright
Some API interfaces purchased by Yiwu hope to bring you some help
[half understood] zero value copy
Redis implements distributed locks
[try to hack] intranet Foundation
开源汇智创未来 | 2022 开放原子全球开源峰会 OpenAtom openEuler 分论坛圆满召开
Is it overtime to be on duty? Take up legal weapons to protect your legitimate rights and interests. It's time to rectify the working environment
界面控件Telerik UI for WPF - 如何使用RadSpreadsheet记录或评论
Uniapp wechat applet realizes the function of connecting low-power Bluetooth printing
1331. 数组序号转换 : 简单模拟题
Holes in [apue] files
SuperMap arsurvey license module division
Using Arduino to develop esp8266 to build a development environment
Use json.stringify() to format data
IRBuilder
Open source office (ospo) unveils Secrets
Did kafaka lose the message
Hongjiu fruit passed the hearing: five month operating profit of 900million Ali and China agricultural reclamation are shareholders
用arduino开发ESP8266 搭建开发环境