1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
| x_lis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y_lis = [2, 2, 3, 4, 5, 3, 7, 8, 9, 5]
# 设置散点图
s=Scatter(init_opts=opts.InitOpts(
width="300px",
height="300px"
)
)
s.add_xaxis(x_lis)
s.add_yaxis("标签",y_lis, label_opts=opts.LabelOpts(is_show=True))
# max_interval 指定坐标轴间隔
s.set_global_opts(
title_opts=opts.TitleOpts(title="散点图"),
xaxis_opts=opts.AxisOpts(
type_='value',
splitline_opts=opts.SplitLineOpts(is_show=True),
max_interval=1
),
yaxis_opts=opts.AxisOpts(
splitline_opts=opts.SplitLineOpts(is_show=True),
axistick_opts=opts.AxisTickOpts(is_show=True,length=10),
max_interval=1
),
)
# 设置参考线
line1 = (
Line()
.add_xaxis([0,10])
.add_yaxis(
"",
list([0,10]),
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(
xaxis_opts=opts.AxisOpts(
type_='value',
)
)
)
# 设置overlap
overlap_1 = s.overlap(line1)
grid = (
Grid(init_opts=opts.InitOpts(width="300px", height="300px"))
.add(
overlap_1, grid_opts=opts.GridOpts(), is_control_axis_index=True
)
.render_notebook()
)
grid
|