首页 > 解决方案 > Altair Changing legend color

问题描述

I am trying to change the colors of the selected fields that I have highighted red in the image below but I am unsure about how exacly I would do it. I am trying to update the chart legend text color and allso the titles of the data sources color.

Chart Title

chart = alt.Chart(df).mark_text(align='center', fontSize=48, fontWeight=200, opacity=0.5, text='foo-baz').mark_bar().encode(
    # tell Altair which field to group columns on
    x=alt.X('c2:N', title=None),

    # tell Altair which field to use as Y values and how to calculate
    y=alt.Y('sum(values):Q',
            axis=alt.Axis(
                grid=False,
                title='LOC added')),
    # tell Altair which field to use to use as the set of columns to be  represented in each group
    column=alt.Column('c1:N', title=None),
    # tell Altair which field to use for color segmentation
    color=alt.Color('Language:N',
                    scale=alt.Scale(
                        domain=all_languages,
                        # make it look pretty with an enjoyable color pallet
                        range=allColorsValues,
                    ),

                    )).configure(background='transparent')\
    .configure_view(
    # remove grid lines around column clusters
    strokeOpacity=0,
).configure_axis(
    labelColor='white',
    titleColor='white'
).configure_legend(
    strokeColor='gray'
)

标签: altair

解决方案


推荐阅读