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

Strip Plot with Jitter example is broken for HTML #3321

Open
tbenst opened this issue Jan 29, 2024 · 4 comments
Open

Strip Plot with Jitter example is broken for HTML #3321

tbenst opened this issue Jan 29, 2024 · 4 comments
Labels

Comments

@tbenst
Copy link

tbenst commented Jan 29, 2024

For this example: https://altair-viz.github.io/gallery/strip_plot_jitter.html

mimetype works, HTML backend does not. I think this is either a bug, or should be documented on the example page.

Tested using VSCode Interactive Python.

import altair as alt
from vega_datasets import data
alt.renderers.enable('mimetype') # delete this to break plot
source = data.movies.url

gaussian_jitter = alt.Chart(source, title='Normally distributed jitter').mark_circle(size=8).encode(
    y="Major_Genre:N",
    x="IMDB_Rating:Q",
    yOffset="jitter:Q",
    color=alt.Color('Major_Genre:N', legend=None)
).transform_calculate(
    # Generate Gaussian jitter with a Box-Muller transform
    jitter="sqrt(-2*log(random()))*cos(2*PI*random())"
)

uniform_jitter = gaussian_jitter.transform_calculate(
    # Generate uniform jitter
    jitter='random()'
).encode(
    y=alt.Y('Major_Genre:N', axis=None)
).properties(
    title='Uniformly distributed jitter'
)

(gaussian_jitter | uniform_jitter).resolve_scale(yOffset='independent')

mime
jitter

@tbenst tbenst added the bug label Jan 29, 2024
@joelostblom
Copy link
Contributor

I just tried this in both VS Code 1.86.0-insider and jupyterlab 4. For me it works fine with the HTML renderer in both environments. Could you try updating VS code to see if the problem goes away (or report which version of VSCode and Altair you see the issue with?)

@tbenst
Copy link
Author

tbenst commented Jan 29, 2024

Thanks kindly for checking!

altair                   5.2.0
macOS 13.4

VSCode version:
Version: 1.85.2
Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
Date: 2024-01-18T06:40:11.430Z (1 wk ago)

Edit: I just realized that the issue only occurs when using remote-ssh, in my case to a headless Linux machine. otherwise, the plot comes through fine. Also, the plot still saves to file correctly so it's exclusively a remote-ssh display issue

@joelostblom
Copy link
Contributor

Edit: I just realized that the issue only occurs when using remote-ssh, in my case to a headless Linux machine. otherwise, the plot comes through fine. Also, the plot still saves to file correctly so it's exclusively a remote-ssh display issue

Interesting, unfortunately I have don't have a good sense for why remote-ssh would impact just the chart transformations and not the display.

@binste
Copy link
Contributor

binste commented Feb 4, 2024

Could you try to:

  1. Clear all cell outputs in the notebook
  2. Restart the kernel
  3. Reload VS Code
  4. Run again the cell

Or try it in a new notebook. Maybe an old version of Vega-Lite is still loaded from some other cell in that same notebook?

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

3 participants