79701178

Date: 2025-07-14 17:11:41
Score: 1
Natty:
Report link

You can tell altair to resolve the color scales seperately:

a1 = (alt.Chart(df.filter(pl.col('class')=="A"))
    .mark_bar()
    .encode(x='x', y='y', color=alt.Color('y', scale=alt.Scale(scheme="greens"))))

a2 = (alt.Chart(df.filter(pl.col('class')=="B"))
    .mark_bar()
    .encode(x='x', y='y', color=alt.Color('y', scale=alt.Scale(scheme="oranges"))))

(a1 | a2).resolve_scale(color="independent")

image of independent scale

More info in the docs.

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: kgoodrick