简体   繁体   English

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

[英]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.我将填充颜色更改为红色,我也想更改线条颜色,但无论我做什么它都保持blue I tried changing fill , stroke and color to red , but the line still stays 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')

在此处输入图像描述

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.设置color='red'stroke='red'应该可以工作,但不能:这可能是 Vega 或 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')

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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