代码之家  ›  专栏  ›  技术社区  ›  user3556757

控制轴的标题标签颜色

  •  0
  • user3556757  · 技术社区  · 6 年前

    正在努力设置轴标签的颜色。

    base = alt.Chart(xf.loc['2017':].reset_index(), title="trouble").encode(
        x='Date'
    )
    
    rigs = base.mark_line(color='blue').encode(
        alt.Y('Total Oil Rigs', scale=alt.Scale(zero=False),axis=alt.Axis( title='I should BLUE'))
    )
    
    prod = base.mark_line(color='green').encode(
        alt.Y('US Crude Production', scale=alt.Scale(zero=False),axis=alt.Axis( title='I should be GREEN'))
    )
    
    alt.layer(
        rigs,
        prod
    ).resolve_scale(
        y='independent'
    ).configure_axisLeft(labelColor='blue').configure_axisRight(labelColor='green')
    

    我可以使用 configure_axisLeft/Right() altair.Axis enter image description here

    0 回复  |  直到 6 年前
        1
  •  3
  •   jakevdp    6 年前

    你可以用 titleColor 配置:

    chart.configure_axisLeft(
      labelColor='blue'
      titleColor='blue'
    ).configure_axisRight(
      labelColor='green',
      titleColor='green'
    )
    
    推荐文章