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

Altair plots cannot be embedded into html when panel is run from a script #2367

Closed
joelostblom opened this issue Jun 10, 2021 · 0 comments · Fixed by #2452
Closed

Altair plots cannot be embedded into html when panel is run from a script #2367

joelostblom opened this issue Jun 10, 2021 · 0 comments · Fixed by #2452
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@joelostblom
Copy link
Contributor

Embeding Altair plots to an html file from a notebok works, and the saved file from the code below has embedded the plot for the different selections in the dropdown as expected. However, running it from a script does not work. I am thinking it has something to do with the vega extension needing the notebook environment to create an Altair plot, but might be wrong. If this is the case, maybe it would be useful to have a warning when trying to run this from a script, since embedding other components such as text etc works as expected.

import altair as alt
from vega_datasets import data
import panel as pn
from panel.interact import interact


pn.extension('vega')

cars = data.cars()

def scatter_plot(x_column):
    chart = alt.Chart(cars).mark_point().encode(
        x=x_column,
        y='Displacement')
    return chart

interact(scatter_plot, x_column=cars.select_dtypes('number').columns).save('test3.html', embed=True)

ALL software version info

session_info.show()
-----
altair              4.1.0
pandas              1.2.4
panel               0.11.3
session_info        1.0.0
vega_datasets       0.9.0
-----
IPython             7.24.1
jupyter_client      6.1.12
jupyter_core        4.7.1
jupyterlab          2.3.1
notebook            6.4.0
-----
Python 3.8.10 | packaged by conda-forge | (default, May 11 2021, 07:01:05) [GCC 9.3.0]
Linux-5.11.0-7614-generic-x86_64-with-glibc2.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants