如何更改 Altair 的 Filled Step 图表中的线条颜色?

How do I change the line color in Altair's Filled Step chart?

我正在直接处理来自文档的 example。 我将填充颜色更改为红色,我还想更改线条颜色,但无论我做什么,它都会保持 blue。我尝试将 fillstrokecolor 更改为 red,但行仍然保持 blue.

import altair as alt
from vega_datasets import data

source = data.stocks()

alt.Chart(source).mark_area(
    color="red",
    fill="red",
    interpolate='step-after',
    line=True
).encode(
    x='date',
    y='price'
).transform_filter(alt.datum.symbol == 'GOOG')

我是不是漏掉了一些琐碎的东西?

设置 color='red'stroke='red' 应该有效,但没有:这可能是 Vega 或 Vega-Lite 中的错误。但是您可以通过将颜色编码设置为一个值来解决它:

import altair as alt
from vega_datasets import data

source = data.stocks()

alt.Chart(source).mark_area(
    fill="red",
    interpolate='step-after',
    line=True
).encode(
    x='date',
    y='price',
    color=alt.value('red')
).transform_filter(alt.datum.symbol == 'GOOG')