【问题标题】:Invalid specification altair.vegalite.v4.schema.channels.Color, validating 'required' 'type' is a required property无效的规范 altair.vegalite.v4.schema.channels.Color,验证 'required' 'type' 是必需的属性
【发布时间】: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

【问题讨论】:

    标签: colors altair


    【解决方案1】:

    我想你想要的是这样的:

    color=alt.value("#f4a582")
    

    【讨论】:

      猜你喜欢
      • 2016-01-05
      • 1970-01-01
      • 2016-09-06
      • 2021-07-20
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多