vahndi
vahndi

Reputation: 1045

Set colors for individual points in altair

Given a DataFrame data of point coordinates 'x', 'y' and hex string colors (e.g. '#ab1234'), how do I set the color of each point using the 'color' column? I have tried the following but in both cases the colors appear random:

from altair import Chart

points = Chart(data).mark_point().encode(
    x='x:Q',
    y='y:Q'
).encode(color='color')

points = Chart(data).mark_point().encode(
    x='x:Q',
    y='y:Q',
    color='color'
)

Upvotes: 0

Views: 263

Answers (1)

debbes
debbes

Reputation: 942

color=alt.Color('color:N', scale=None) should work.

Upvotes: 2

Related Questions