question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Altair (vegalite beneath the hood, I think?) plots not appearing in native interactive window

See original GitHub issue

Environment data

  • VS Code version: 1.59.1
  • Jupyter Extension version (available under the Extensions sidebar): v2021.8.1236758218
  • Python Extension version (available under the Extensions sidebar): v2021.10.1183791216-dev
  • OS (Windows | Mac | Linux distro) and version: macOS 11.5.2 (20G95)
  • Python and/or Anaconda version: 3.9.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Jupyter server running: Local

Expected behaviour

Altair chart to appear in interactive window

Actual behaviour

Doesn’t appear. If you switch the Mimetype to text/plain then back to text/HTML, it does appear. Works fine in notebook.

Steps to reproduce:

Run this code:


import pandas as pd

# Download World Development Indicators
wdi = pd.read_csv(
    "https://media.githubusercontent.com/media/nickeubank/"
    "MIDS_Data/master/World_Development_Indicators/wdi_small_tidy_2015.csv"
)

# Plot
import altair as alt

my_chart = (
    alt.Chart(wdi)
    .mark_circle(size=50)
    .encode(
        x="GDP per capita (constant 2010 US$)",
        y="Mortality rate, under-5 (per 1,000 live births)",
        tooltip=["Country Name"],
    )
    .interactive()
)
my_chart

interactive_plot_failure_mwe.py.zip

interactive_no_plot

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

Started kernel Python 3.9.6 64-bit ('base': conda)
Info 2021-09-01 14:23:48: Initial setup for vscode-interactive:Interactive-1.interactive starting ...
Info 2021-09-01 14:23:48: UpdateWorkingDirectoryAndPath
Info 2021-09-01 14:23:48: Kernel switching to busy
Info 2021-09-01 14:23:48: Kernel switching to idle
Info 2021-09-01 14:23:48: Kernel switching to busy
Info 2021-09-01 14:23:48: Kernel switching to idle
Info 2021-09-01 14:23:48: Initial setup complete for vscode-interactive:Interactive-1.interactive
Info 2021-09-01 14:23:48: Finished connecting 271e106e-2485-4f22-b0ea-3ffbe3081910
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_kernelOptions
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Registering commtarget jupyter.widget
Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_mirror_execute
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: IPyWidgetScriptSource.initialize
Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Kernel switching to busy
Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_registerCommTarget
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_registerCommTarget
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize
Info 2021-09-01 14:23:48: IPyWidgetMessageDispatcher.initialize
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Kernel switching to idle
Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: UpdateWorkingDirectoryAndPath
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: changeDirectoryIfPossible
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_mirror_execute
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Kernel switching to busy
Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Kernel switching to idle
Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_mirror_execute
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Kernel switching to busy
Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Kernel switching to idle
Info 2021-09-01 14:23:48: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle
Info 2021-09-01 14:23:48: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:48: Posting message to Notebook UI 
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:48: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:48: Waiting for idle on (kernel): 426902a7-37f1-452e-a388-d2cce5767320 -> idle
Info 2021-09-01 14:23:48: Finished waiting for idle on (kernel): 426902a7-37f1-452e-a388-d2cce5767320 -> idle
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: UpdateWorkingDirectoryAndPath
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_mirror_execute
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Kernel switching to busy
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy
Info 2021-09-01 14:23:49: Kernel switching to idle
Info 2021-09-01 14:23:49: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Adding hash for 1 = 9e88cef7578d with 23 lines
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_mirror_execute
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:49: Posting message to Notebook UI 
Info 2021-09-01 14:23:49: Kernel switching to busy
Info 2021-09-01 14:23:49: Notebook Session status vscode-interactive:Interactive-1.interactive # Busy
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:49: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:51: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:51: Posting message to Notebook UI 
Info 2021-09-01 14:23:51: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:51: Posting message to Notebook UI 
Info 2021-09-01 14:23:51: Kernel switching to idle
Info 2021-09-01 14:23:51: Notebook Session status vscode-interactive:Interactive-1.interactive # Idle
Info 2021-09-01 14:23:51: Widget Coordinator sent IPyWidgets_msg
Info 2021-09-01 14:23:51: Posting message to Notebook UI 
Info 2021-09-01 14:23:51: Finished execution for 3caab3e6-7062-4834-b3df-0802006862f3
Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_msg_received
Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-09-01 14:23:52: Widget Coordinator received IPyWidgets_msg_received

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, Sep 1, 2021

Oh actually this works for me in insiders. In stable VS code I repro the bug you have. This looks like it’s been fixed in the last month.

0reactions
rchiodocommented, Sep 1, 2021

New stable VS code version is coming out today? Tomorrow maybe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Display Troubleshooting — Altair 4.2.0 documentation
If you are using Altair outside of a Jupyter notebook environment (such as a Python or IPython terminal) charts will be displayed as...
Read more >
many interactive examples are not working · Issue #538 - GitHub
Yes, it works fine on that page and when in the 'open with vega editor' link. It is just within jupyter notebook on...
Read more >
Using Altair for most of my visualization in Python | Hacker News
Under the hood it works the same way: Plotly.py generates JSON figure descriptions which are passed to Plotly.js for rendering.
Read more >
altair - Tooltips not appearing for secondary plot - Stack Overflow
A potential workaround is to add interactive() separately to each chart, rather than adding it to the base chart. See also Altair -...
Read more >
An Introduction to Altair - Jim Vallandingham
Altair provides a way to write declarative data visualization code in python by harnessing the power of Vega and Vega-Lite.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found