【发布时间】:2021-12-30 15:23:31
【问题描述】:
我正在尝试使用十六进制代码更改图表的颜色。这是我的代码
Uniq=["Seattle","New York"]
select = alt.selection_single(
name='Select', # name the selection 'Select'
fields=["location"], # limit selection to the Major_Genre field
init={"location": Uniq[1]}, # use first genre entry as initial value
bind=alt.binding_select(options=Uniq) # bind to a menu of unique genre values
)
alt.Chart(weather).mark_point(filled=True, size=15, opacity=0.5).add_selection(
select).encode(
alt.X(alt.repeat('column'), type='quantitative'),
alt.Y(alt.repeat('row'), type='quantitative'),
#alt.Color(scale=alt.Scale(domain=[0,10,20,30,40,50],range=["#ffffff","#bdd7e7","#6baed6","#3182bd","#08519c"])'#f4a582'),
color= alt.Color(alt.value("#f4a582")),
opacity=alt.condition(select, alt.value(0.75), alt.value(0.05))
).properties(
width=125,
height=125
).repeat(
row=['temp_max', 'precipitation', 'wind'],
column=['wind', 'precipitation', 'temp_max']
)
这是我得到的错误。
Invalid specification altair.vegalite.v4.schema.channels.Color, validating 'required' 'type' is a required property
如何在使用重复时更改颜色。 tnx
【问题讨论】: