蚂蚁开源,又一超棒的 Python 开源可视化库(二)
上一篇 /
下一篇 2022-06-20 11:20:01
参数解析&完整代码
各位看官,这块可能比较无聊,可以直接划到文末或者点击收藏。
主要还是详解一下刚才scatter.set_options()里的参数,方便大家后续自己改造!
分成几个部分一点一点解释:
参数解释
'appendPadding': 30, #①
'data': data, #②
'xField': 'change in female rate', #③
'yField': 'change in male rate',
①图表在上右下左的间距,加不加这个参数具体看下图:
②设置图表数据源(其中data在前面已经赋值了),这里的数据源为对象集合,例如:[{ time: '1991',value: 20 }, { time: '1992',value: 20 }]。
③xField和yField这两个参数分别是横/纵向的坐标轴对应的字段。
参数解释
'sizeField': 'pop', #④
'colorField': 'continent', #⑤
'color': ['#ffd500', '#82cab2', '#193442', '#d18768','#7e827a'], #⑥
'size': [4, 30], #⑦
'shape': 'circle', #⑧
④指定散点大小对应的字段名,我们用的pop(人口)字段。
⑤指定散点颜色对应的字段名,我们用的continent(洲)字段。
⑥设置散点的颜色,指定了系列色值。
⑦设置散点的大小,可以指定大小数组 [minSize, maxSize]
⑧设置点的形状,比如cicle、square
参数解释
'pointStyle':{'fillOpacity': 0.8,'stroke': '#bbb'}, #⑨
'xAxis':{'line':{'style':{'stroke': '#aaa'}},}, #⑩
'yAxis':{'line':{'style':{'stroke': '#aaa'}},},
⑨pointStyle是指折线样式,不过在散点图里,指的是散点的描边。另外fillOpacity是设置透明度,stroke是设置描边颜色。
⑩这里只是设置了坐标轴线的颜色。
参数解释
'quadrant':{
'xBaseline': 0,
'yBaseline': 0,
'labels': [
{'content': 'Male decrease,\nfemale increase'},
{'content': 'Female decrease,\nmale increase'},
{'content': 'Female & male decrease'},
{'content': 'Female &\n male increase'}, ],},
quadrant是四象限组件,具体细分配置如下:
PyG2Plot的介绍文档还不完善,上文中的很多参数是摸索的,大家作为参考就好。
PyG2Plot 原理其实非常简单,其中借鉴了 pyecharts 的实现,但是因为蚂蚁金服的 G2Plot 完全基于可视分析理论的配置式结构,所以封装上比 pyecharts 简洁非常非常多。
收藏
举报
TAG:
软件开发
Python