yes
yes

Reputation: 261

Altair: multiple y-axes on same chart

I want to know how to make a plot like this (a plot having multiple y-axes), but in altair:

Upvotes: 2

Views: 1173

Answers (1)

yes
yes

Reputation: 261

Start with a layered plot:

base = alt.Chart(df).encode(
    x='time'
)
line = base.mark_line().encode(
    y='exp'
)
circle =  base.mark_circle().encode(
    y='sin'
)

Then when you 'call' the chart with (line + circle), you add .resolve_scale(y='independent')

(line + circle).resolve_scale(
    y = 'independent'
)

Upvotes: 4

Related Questions