[英]Altair: Line Chart with Stroked Point Markers
我正在尝试在 Altair 中创建带有点标记的折线图。 我正在使用 Altair 文档中的多系列折线图示例,并尝试将其与 Vega-Lite 文档中带有描边点标记示例的折线图结合起来。
我感到困惑的是如何处理“mark_line”参数。 从 Vega 示例中,我需要使用“点”,然后将“填充”设置为 False。
"mark": {
"type": "line",
"point": {
"filled": false,
"fill": "white"
}
},
我将如何在 Altair 中应用它? 我发现将 'point' 设置为 'True' 或 '{}' 添加了一个点标记,但对如何让填充起作用感到困惑。
source = data.stocks()
alt.Chart(source).mark_line(
point=True
).encode(
x='date',
y='price',
color='symbol'
)
您始终可以将原始 vega-lite dict 传递给 Altair 中的任何属性:
source = data.stocks()
alt.Chart(source).mark_line(
point={
"filled": False,
"fill": "white"
}
).encode(
x='date',
y='price',
color='symbol'
)
或者您可以检查mark_line()
的文档字符串,并看到它期望 point 是OverlayMarkDef()
并使用 Python 包装器:
alt.Chart(source).mark_line(
point=alt.OverlayMarkDef(filled=False, fill='white')
).encode(
x='date',
y='price',
color='symbol'
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.