Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dual axis with overlapping plot not showing ticks #3359

Open
fkgruber opened this issue Mar 13, 2024 · 2 comments
Open

dual axis with overlapping plot not showing ticks #3359

fkgruber opened this issue Mar 13, 2024 · 2 comments
Labels

Comments

@fkgruber
Copy link

fkgruber commented Mar 13, 2024

I would like to have 2 y axis where the units are different. However, it seems altair is removing the ticks of the second y axis. Probably because the plot is overlapping

is there a way around this?

import altair as alt
from vega_datasets import data

source = data.cars()

base = alt.Chart(source).encode(x='year(Year):T')

line_A = base.mark_line(color='#5276A7').encode(
    alt.Y('average(Horsepower):Q').axis(titleColor='#5276A7',title='Horsepower')
)

line_B = base.mark_line(color='#F18727').encode(
    alt.Y('average(Horsepower)/100:Q').axis(title="Percentage",titleColor='#F18727')
)
alt.layer(line_A, line_B).resolve_scale(y='independent')
image
@fkgruber fkgruber added the bug label Mar 13, 2024
@joelostblom
Copy link
Contributor

It's because you can't do the computation inside the encoding, is need to be in a transform_calculate (only some aggregate computation are supported directly in the encoding string). If you remove /100 you get this which sounds like what you want?

image

@fkgruber
Copy link
Author

oh I see. I will try that thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants