.add_yaxis('类型1', df['type1'].tolist()) .add_yaxis('类型2', df['type2'].tolist()) .add_yaxis('类型3', df['type3'].tolist())换成循环语句
时间: 2023-09-29 16:06:17 浏览: 99
循环语句1
可以使用循环语句和列表推导式来实现:
```
types = ['类型1', '类型2', '类型3']
data = [df[t].tolist() for t in types]
line = Line()
for i in range(len(types)):
line.add_yaxis(types[i], data[i])
```
或者更简洁的写法:
```
types = ['类型1', '类型2', '类型3']
line = Line()
[line.add_yaxis(t, df[t].tolist()) for t in types]
```
阅读全文