-
Notifications
You must be signed in to change notification settings - Fork 602
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Logarithmic scale not showing any results #9373
Comments
By default, the bar chart draws a bar from 0 to the y encoding value. It's not possible to include 0 in a logarithmic scale, so it does not draw anything. You can fix this by giving vega-lite an alternative starting ___location for the bar that can be represented on a logarithmic scale. You can do this by providing a constant "y2" encoding e.g. "y2": {"datum": 0.1} Working example here. |
Thanks for explaining. But in my example, there is no datum with a y value of 0. Am I missing something? |
Hi @mscolnick, the 0 is implied with bar mark which is generally desirable as almost all bar charts go from 0 to the value. Since this is not possible with a logarithmic scale you have to tell vega-lite what you want it to do by manually setting a datum that can be represented on a log scale. |
Got it - thanks for clarifying. What's weird is that when Altair renders this, it works, but the "Open in Vega Editor" still does not work. 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"),
),
)
) But the produced vega playground, that can be found here, still does not render (due to the y=0 issue mentioned above). |
For some reason, the same spec in the online editor introduces a stack transform in the compiled Vega which is what is causing the issue. Maybe one of the devs will know why. |
Thank you - I filed an issue in the Altair repo: vega/altair#3447 EDIT: They believe this (vega-lite) is the is the correct place for the issue |
What solution do you propose? Not implying automatic zero for bars when the scale is log? |
@domoritz - i'm not familiar enough with vega-lite to propose a solution, but is this not a regression? is anything wrong with the previous implementation? |
Bug Description
Logarithmic scale not showing any results. This works when removing
"scale"
or changing to"symlog"
.https://vega.github.io/editor/#/url/vega-lite/N4Igxg9gdgZglgcxALlANzgUwO4tJKAFzigFcJSBnAdTgBNCALFAZgAY2AacaYsiygAlMiRoVYcAvpO50AhoTl4QUOQFtMKEPMUgZINXIBOAa2WEAngAdNyEACNjIbpUJGIJ2w4A2csGZc3D0xaBmZkNgA6AFZ9TChIOhIkVBAAD2V4TG86LQzuSxstAEdSOSI4RWI0TX0LTKwcrXqXMDlvW1BCr28IJH1ukrKKqrgavX0AEkowRkxDLTFCK0pkAHo1moQ5SIRKxlJ7SLgINZm5w03MbYBab0rMTejIgEYAdkiogCtKaGdtBRySiYQiUZQ6JTIADaoAyyBe3HqyFinFhKAATIiUC82DI0cgWFjkOi8ekUAAWIkADlJcOiRJYtJQADYiS8Ufi3mymcgqUTyTyAJxEwU8nFE5mSAC60iAA
Checklist
The text was updated successfully, but these errors were encountered: