简体   繁体   中英

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

I am working directly on the example from the docs. I changed the fill color to red and I also want to change the line color, but it stays blue no matter what I do. I tried changing fill , stroke and color to red , but the line still stays 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')

在此处输入图像描述

Am I missing something trivial?

Setting color='red' or stroke='red' should work, but doesn't: this is probably a bug in Vega or Vega-Lite. But you can work around it by setting the color encoding to a value:

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')

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM