altair
altair copied to clipboard
Strip Plot with Jitter example is broken for HTML
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')
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?)
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
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.
Could you try to:
- Clear all cell outputs in the notebook
- Restart the kernel
- Reload VS Code
- 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?