-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathline_with_two_xaxis.py
More file actions
33 lines (26 loc) · 1017 Bytes
/
line_with_two_xaxis.py
File metadata and controls
33 lines (26 loc) · 1017 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : AwesomeTang
# @File : line_with_two_xaxis.py
# @Version : Python 3.7
# @Time : 2020-11-22 10:00
from pyecharts.charts import *
from pyecharts import options as opts
import random
x_data_1 = ["2020/10/{}".format(i + 1) for i in range(30)]
x_data_2 = ["2019/10/{}".format(i + 1) for i in range(30)]
y_data_1 = [random.randint(10, 50) for _ in range(30)]
y_data_2 = [random.randint(20, 60) for _ in range(30)]
def line_with_two_xaxis():
line = Line(init_opts=opts.InitOpts(theme='light',
width='1000px',
height='600px'))
line.add_xaxis(x_data_1)
# 添加一个x轴
line.extend_axis(xaxis_data=x_data_2, xaxis=opts.AxisOpts())
line.add_yaxis('下面X轴', y_data_1)
line.add_yaxis('上面X轴', y_data_2)
return line
if __name__ == '__main__':
chart = line_with_two_xaxis()
chart.render(path='chart_output/line_with_two_xaxis.html')