vega / altair

Declarative statistical visualization library for Python
https://altair-viz.github.io/
BSD 3-Clause "New" or "Revised" License
9.34k stars 794 forks source link

Log scale bar chart renders correct chart, but not working generated vega-spec #3447

Open mscolnick opened 4 months ago

mscolnick commented 4 months ago

What happened?

I have this altair code that produces a working chart, but the generate vega-lite spec does not render correctly.

For example, here is a reproduction: https://marimo.app/l/nhwpi8

import altair as alt
import pandas as pd
data = {"x": range(1, 11), "y": [5, 10, 2, 8, 3, 15, 1, 4, 9, 6]}
df = pd.DataFrame(data)

(
    alt.Chart(df)
    .mark_bar(stroke="black", strokeWidth=0.5)
    .encode(
        x=alt.X(
            "x",
        ),
        y=alt.Y(
            "y",
            scale=alt.Scale(type="log"),
        ),
    )
)
image

But the produced vega playground, that can be found here, does not render properly with log scale.

I have filed an issue on vega-lite, but this seems to be downstream: https://github.com/vega/vega-lite/issues/9373

What would you like to happen instead?

The produced vega-lite code matches the rendered chart.

Which version of Altair are you using?

5.3.0

mattijn commented 4 months ago

Thanks for raising! The latest version of Altair compiles to Vega-lite 5.17, but the latest Vega-lite version is 5.19. So this behavior might be a potential regression introduced in VL version 5.18 or 5.19. I say potential, because I'm not sure if it was intentional.

Personally, I'm fine with a default for log-scales (1 it seems), just as linear-scales have a default (0).

It is something we need to be aware of when upgrading, but it is not something we control.

So your current issue at the VL repository is the appropriate place to raise this issue.