简体   繁体   English

如何使用 Altair 更改折线图中的线 colors

[英]How to change line colors in line chart using Altair

I'd like to change the colors of the lines in this line chart but when I created a code to do that, nothing happened.我想更改此折线图中线条的 colors,但是当我创建代码来执行此操作时,没有任何反应。 I'd like to change the colors so the lines are green and yellow instead of orange and blue:我想更改 colors,使线条为绿色和黄色,而不是橙色和蓝色:

1个

This is the code I'm using to design the visual with my attempt at changing the colors that didn't work but still populated this chart:这是我用来设计视觉效果的代码,我尝试更改 colors,它不起作用但仍然填充此图表:

# team names
domain = ['☘️🍀🇮🇪', '💸🤑💰💵']
# line colors
range_ = ['gold','green']

# creating the line chart
tweet = alt.Chart(ndf).mark_line().encode(
    x='average(datetime)',
    y='tweet_count',
    stroke='team',
    color=alt.Color('team',scale=alt.Scale(domain=domain,range=range_)))

tweet

删除stroke编码或将其设置为使用与color编码相同的范围。

I suggest trying this:我建议试试这个:

color=alt.Color('team', scale={"range": ["yellow", "orange"]})

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

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