整理自官网
from pyecharts.globals import CurrentConfig, OnlineHostType
CurrentConfig.ONLINE_HOST = OnlineHostType.NOTEBOOK_HOST
散点图-多图
from pyecharts.charts import Scatter,EffectScatter
import numpy as np
y = np.random.randint(1,30,50).tolist()
s = EffectScatter()
s.add_xaxis(xaxis_data=range(50))
s.add_yaxis('A', y_axis=y, symbol='pin',symbol_size=16,label_opts=opts.LabelOpts(is_show=False))
s.set_global_opts(
title_opts=opts.TitleOpts(title='散点图-涟漪特效散点'),
xaxis_opts=opts.AxisOpts(name='秒'),
yaxis_opts=opts.AxisOpts(name='流量'),
legend_opts=opts.LegendOpts(pos_right=50),
# series_index指定映射的系列索引
visualmap_opts=[
opts.VisualMapOpts(type_='color', min_=0,max_=50,series_index=0, pos_top='20px'),
opts.VisualMapOpts(type_='size', min_=0,max_=50,series_index=1, pos_top='60%')
]
)
s2 = Scatter()
s2.add_xaxis(xaxis_data=range(50))
s2.add_yaxis('B', y_axis=y,
xaxis_index=1, yaxis_index=1,
label_opts=opts.LabelOpts(is_show=False))
s2.set_global_opts(
xaxis_opts=opts.AxisOpts(name='秒', grid_index=1),
yaxis_opts=opts.AxisOpts(name='流量'),
legend_opts=opts.LegendOpts(pos_right=10),
)
g = Grid(init_opts=opts.InitOpts(height='450px', width='850px'))
g.add(s,grid_opts=opts.GridOpts(height="35%")) # 高度变为35%
g.add(s2,grid_opts=opts.GridOpts(pos_top='60%',height="35%")) # 距离容器顶部的距离
g.render_notebook()
平行坐标系
from pyecharts.charts import Parallel
平行坐标系-基本设置
r = np.random.rand(12)
data = [[i, round(j,2), round(m,2), n] for i,j,m,n in zip(range(12),r,np.random.randint(1,3,12)+r, np.random.choice(['A','B'],12))]
data[:3]
[[0, 0.04, 1.04, ‘A’], [1, 0.9, 1.9, ‘A’], [2, 0.11, 2.11, ‘B’]]
# 坐标轴设置,类别轴设置data所有的类别
schema = [
{
'dim':0,'name':'月份'},{
'dim':1,'name':'指标1'},
{
'dim':2