我想突出显示Altair中2条线之间的区域。

我试图查看解决方案是否正在使用,mark_area()但找不到如何指定数据下限。
我的数据(几行):
index created pct_pl_transit pct_pl_transit_max
0 1970-01-01 00:00:00 49.627697 60.056873
2 1970-01-01 01:00:00 43.800967 55.301460
4 1970-01-01 02:00:00 41.440480 49.757740
6 1970-01-01 03:00:00 37.879753 40.352226
8 1970-01-01 04:00:00 36.691287 19.429075
Run Code Online (Sandbox Code Playgroud)
我的图表:
base=alt.Chart(lien_traf_gest_traf_lapi).encode(x=alt.X('created', axis=alt.Axis(title='Heure', format='%Hh%M')))
line_pct_pl_lapi=base.mark_line(color='blue').encode(y=alt.Y('pct_pl_transit:Q', axis=alt.Axis(title='Nombre de PL SIREDO')))
line_pct_max=base.mark_line().encode(y='pct_pl_transit_max')
line_pct_max+line_pct_pl_lapi
Run Code Online (Sandbox Code Playgroud)
您可以使用y和y2编码mark_area()来填充两个值之间的区域。例如:
import altair as alt
import pandas as pd
df = pd.DataFrame({
'x': range(5),
'ymin': [1, 3, 2, 4, 5],
'ymax': [2, 1, 3, 6, 4]
})
alt.Chart(df).mark_area().encode(
x='x:Q',
y='ymin:Q',
y2='ymax:Q'
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
170 次 |
| 最近记录: |