如何使用 Altair 更改折线图中的线条颜色
How to change line colors in line chart using Altair
我想更改此折线图中线条的颜色,但是当我创建代码来执行此操作时,没有任何反应。我想更改颜色,使线条为绿色和黄色而不是橙色和蓝色:
这是我用来设计视觉效果的代码,我尝试更改不起作用但仍然填充此图表的颜色:
# 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
编码相同的范围。
我建议试试这个:
color=alt.Color('team', scale={"range": ["yellow", "orange"]})
我想更改此折线图中线条的颜色,但是当我创建代码来执行此操作时,没有任何反应。我想更改颜色,使线条为绿色和黄色而不是橙色和蓝色:
这是我用来设计视觉效果的代码,我尝试更改不起作用但仍然填充此图表的颜色:
# 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
编码相同的范围。
我建议试试这个:
color=alt.Color('team', scale={"range": ["yellow", "orange"]})