当前位置:网站首页>Pyechart drawing multiple Y-axis line graphs
Pyechart drawing multiple Y-axis line graphs
2022-06-28 20:43:00 【Enter into self pleasure】
pyechart Draw multiple lines y Axonometric chart
Draw three polylines , And use different y Axis : Use the following data to draw a line chart , And set according to the unit y Axis
data :
x_data=['06-24 21:00','06-24 20:00','06-24 19:00','06-24 18:00', #x Axis
'06-24 17:00','06-24 16:00','06-24 15:00','06-24 14:00','06-24 13:00',
'06-24 12:00','06-24 11:00','06-24 10:00','06-24 09:00','06-24 08:00',
'06-24 07:00','06-24 06:00','06-24 05:00','06-24 04:00','06-24 03:00',
'06-24 02:00','06-24 01:00','06-24 00:00','06-23 23:00','06-23 22:00']
pm25=[20.0,24.0,26.0,24.0,21.0,19.0,19.0,18.0,17.0,16.0,19.0,21.0,23.0, #y0 Axis Company ug/m³
26.0,28.0,26.0,26.0,26.0,26.0,25.0,25.0,26.0,25.0,24.0,]
aqi=[52.0,94.0,116.0,138.0,139.0,133.0,128.0,120.0,112.0,110.0,105.0, #y1 Axis No unit
70.0,58.0,57.0,52.0,51.0,49.0,48.0,51.0,53.0,51.0,53.0,54.0,73.0,]
co=[0.434,0.444,0.52,0.519,0.495,0.49,0.508,0.503,0.498,0.499,0.55,0.642, #y2 Axis Company mg/m³
0.727,0.8,0.819,0.767,0.752,0.729,0.72,0.743,0.755,0.753,0.767,0.748,]
Adding y Use... For axis data yaxis_index Appoint y The index of the axis ,`
line.add_yaxis( # The first curve
series_name='PM2.5',
y_axis=pm25,
label_opts=opts.LabelOpts(is_show=False),
yaxis_index=0, # Set up y Index axis
is_smooth=True,
)
line.add_yaxis( # Add the second curve
series_name='AQI',
y_axis=aqi,
label_opts=opts.LabelOpts(is_show=False),
yaxis_index=1, # Set up y Index axis
is_smooth=True,
)
line.add_yaxis( # Add a third curve
series_name='CO',
y_axis=co,
label_opts=opts.LabelOpts(is_show=False),
yaxis_index=2, # Set up y Axis
is_smooth=True,
)
Use extend_axis Method add y Axis and specify format ,position Parameter settings add y Axis position ,position='left' For the left ,position='right' For the right ;offset Parameter settings y Distance between axes . Added y Axis index from yaxis_index=1 Start .yaxis_index=0 Mainly y Axis , stay set_global_opts Set its specific format in .
line.extend_axis(
yaxis=opts.AxisOpts(type_='value', position='right'))
line.extend_axis(
yaxis=opts.AxisOpts(
name='mg/m³',
type_='value',
position='left', offset=40))
design sketch :
All the code :
import pyecharts.options as opts
from pyecharts.charts import Line
x_data=['06-24 21:00','06-24 20:00','06-24 19:00','06-24 18:00', #x Axis
'06-24 17:00','06-24 16:00','06-24 15:00','06-24 14:00','06-24 13:00',
'06-24 12:00','06-24 11:00','06-24 10:00','06-24 09:00','06-24 08:00',
'06-24 07:00','06-24 06:00','06-24 05:00','06-24 04:00','06-24 03:00',
'06-24 02:00','06-24 01:00','06-24 00:00','06-23 23:00','06-23 22:00']
pm25=[20.0,24.0,26.0,24.0,21.0,19.0,19.0,18.0,17.0,16.0,19.0,21.0,23.0, #y0 Axis Company ug/m³
26.0,28.0,26.0,26.0,26.0,26.0,25.0,25.0,26.0,25.0,24.0,]
aqi=[52.0,94.0,116.0,138.0,139.0,133.0,128.0,120.0,112.0,110.0,105.0, #y1 Axis No unit
70.0,58.0,57.0,52.0,51.0,49.0,48.0,51.0,53.0,51.0,53.0,54.0,73.0,]
co=[0.434,0.444,0.52,0.519,0.495,0.49,0.508,0.503,0.498,0.499,0.55,0.642, #y2 Axis Company mg/m³
0.727,0.8,0.819,0.767,0.752,0.729,0.72,0.743,0.755,0.753,0.767,0.748,]
x_data=x_data[::-1] # In chronological order
pm25=pm25[::-1]
aqi=aqi[::-1]
co=co[::-1]
line=Line().add_xaxis(xaxis_data=x_data) # add to x Axis
line.add_yaxis( # The first curve
series_name='PM2.5',
y_axis=pm25,
label_opts=opts.LabelOpts(is_show=False),
yaxis_index=0, # Set up y Axis
is_smooth=True,
)
line.add_yaxis( # Add the second curve
series_name='AQI',
y_axis=aqi,
label_opts=opts.LabelOpts(is_show=False),
yaxis_index=1, # Set up y Axis
is_smooth=True,
)
line.add_yaxis( # Add a third curve
series_name='CO',
y_axis=co,
label_opts=opts.LabelOpts(is_show=False),
yaxis_index=2, # Set up y Axis
is_smooth=True,
)
line.extend_axis(
yaxis=opts.AxisOpts(type_='value', position='right'))
line.extend_axis(
yaxis=opts.AxisOpts(
name='mg/m³',
type_='value',
position='left', offset=40))
line.set_global_opts(
title_opts=opts.TitleOpts(title='24 Hourly air quality trend chart ',pos_top='top', pos_left='center'),
tooltip_opts=opts.TooltipOpts(trigger="axis"),
yaxis_opts=opts.AxisOpts(
name='ug/m³',
type_="value",
axistick_opts=opts.AxisTickOpts(is_show=True),
splitline_opts=opts.SplitLineOpts(is_show=True),
),
legend_opts=opts.LegendOpts(pos_top='40'),
xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),)
line.render('li.html')
边栏推荐
- 嵌入式中 动态阿拉伯语字符串 转换 LCD显示字符串【感谢建国雄心】
- ComparisonChain-文件名排序
- rapid ssl通配符证书八百一年是正版吗
- 稳定性总结
- SaaS sales upgrade under the new situation | tob Master Course
- Pie (poj3122) super detailed and easy to understand binary introduction
- How to add logs to debug anr problems
- No module named ‘PyEMD‘ ;使用plt.figure()TypeError: ‘module‘ object is not callable
- 2. integrate filter
- Input and output real data
猜你喜欢

Leetcode 36. Effective Sudoku (yes, once)

Jenkins pipeline's handling of job parameters

mysql-发生系统错误1067
How to recover after Oracle delete accidentally deletes table data

Alibaba cloud MSE full link grayscale solution practice based on Apache apisik

Bitbucket failed to pull the warehouse Using SSH

Ehcache配置资料,方便自己查

Data standardization processing

RT-Thread线程同步与线程通信

with torch.no_grad():的使用原因
随机推荐
我也差点“跑路”
Is the rapid SSL wildcard certificate genuine in 1981
输入和输出实型数据
ANR分析--问题1
图神经网络也能用作CV骨干模型,华为诺亚ViG架构媲美CNN、Transformer
Troubleshooting of pyinstaller failed to pack pikepdf
Employee salary management system
Stability summary
2022 welder (elementary) special operation certificate examination question bank and answers
ref属性,props配置,mixin混入,插件,scoped样式
LeetCode每日一题——522. 最长特殊序列 II
Jenkins pipeline's handling of job parameters
1. 整合 Servlet
理解整个网络模型的构建
关于不完全类型的认识
Apisik helps Middle East social software realize localized deployment
[go language questions] go from 0 to entry 5: comprehensive review of map, conditional sentences and circular sentences
Leetcode 36. Effective Sudoku (yes, once)
CNN-LSTM的flatten
输入分隔符