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

marimo altair_chart not displaying log scaled altair chart correctly #1597

Open
andrewhill157 opened this issue Jun 11, 2024 · 4 comments
Open
Labels
bug Something isn't working upstream

Comments

@andrewhill157
Copy link

andrewhill157 commented Jun 11, 2024

Describe the bug

In the example below, the altair chart with passed to mo.ui.altair_chart does not appear to display correctly when the axis is log scaled (not sure if this applies to any other scales)?

image

(note that I had killed my marimo process when took the screenshot, which is why background is red)

Environment

{
"marimo": "0.6.17",
"OS": "Darwin",
"OS Version": "23.5.0",
"Processor": "arm",
"Python Version": "3.10.4",
"Binaries": {
"Browser": "--",
"Node": "v21.7.1"
},
"Requirements": {
"click": "8.1.7",
"importlib-resources": "missing",
"jedi": "0.19.1",
"markdown": "3.5.2",
"pymdown-extensions": "10.7",
"pygments": "2.17.2",
"tomlkit": "0.12.3",
"uvicorn": "0.29.0",
"starlette": "0.37.2",
"websockets": "12.0",
"typing-extensions": "4.9.0",
"black": "23.12.1"
}
}

Code to reproduce

import marimo as mo
import polars as pl
import altair as alt
import pandas as pd
    
def test(scale_type):
    data = {
        'x': range(1, 11),
        'y': [5, 10, 2, 8, 3, 15, 1, 4, 9, 6]
    }
    df = pl.DataFrame(data)

    # return chart with specified scale type for Y
    return (
        alt.Chart(df.to_pandas())
        .mark_bar(stroke="black", strokeWidth=0.5)
        .encode(
            x=alt.X(
                "x",
            ),
            y=alt.Y(
                "y",
                scale=alt.Scale(type=scale_type),
            ),
        )
    )

    # Display the chart
    return chart

linear = test("linear")
log = test("log")
sqrt = test("sqrt")

# Display the altair and mo.ui.altair_chart versions alongside one another
mo.hstack([mo.vstack([linear, log, sqrt]), mo.vstack([mo.ui.altair_chart(linear), mo.ui.altair_chart(log), mo.ui.altair_chart(sqrt)])])
@andrewhill157 andrewhill157 added the bug Something isn't working label Jun 11, 2024
@mscolnick
Copy link
Contributor

Thanks for the easy-to-follow repro. Another interesting bit, when I export both log scales (altair and mo.ui.altair_chart) to the vega editor, neither work:

Altair

mo.ui.altair

@mscolnick
Copy link
Contributor

Still unsure why this fails (even in the vega editor), but symlog seems more reliable than log as a scale setting.

@mscolnick
Copy link
Contributor

Filed two issues to:
vega/altair#3447
vega/vega-lite#9373

@andrewhill157
Copy link
Author

Thank you for filing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

2 participants