Reputation: 617
How can I go about getting the colour scale to center on zero for a diverging colour scale.
Upvotes: 3
Views: 2334
Reputation: 387
We can now use domainMid=0
.
Adapting the example from @jakevdp:
df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
alt.Chart(df).mark_point().encode(
x='x',
y='y',
color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domainMid=0))
)
Upvotes: 3
Reputation: 86330
One way to do this is to explicitly set the domain to be symmetric:
import numpy as np
import pandas as pd
import altair as alt
df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
alt.Chart(df).mark_point().encode(
x='x',
y='y',
color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domain=[-3, 3]))
)
Upvotes: 3