Support in papermill
See original GitHub issueFirstly, Altair is awesome! Trying to get it to work with papermill & jupyter notebooks and running into some issues:
Unsure if this is the proper way to ask this question, but I have some visualizations done in matplotlib that take different parameters and work with papermill (I can run a script to create various versions of a main notebook with slight shifts in the mean / std used in a plot of the normal distribution for example).
I have been trying to replicate the papermill run using Altair (altair==3.0.1) but not able to get an actual output. The process runs without any error, but the final image is not showing in the output notebooks. I did include alt.renderers.enable(‘notebook’).
Below is an example of the basic code I have tried:
# top cell for params
x_marker = "petalLength"
# next cell
import altair as alt
alt.renderers.enable('notebook')
from vega_datasets import data
# ensure injected-params work
print(x_marker)
# final cell
iris = data.iris()
alt.Chart(iris).mark_point().encode(
x=x_marker,
y='petalWidth',
color='species'
)
I then run the following in CL:
papermill papermill_altair_test.ipynb pmill_alt_out.ipynb -p x_ma
rker "sepalLength"
While it builds a notebook w/ proper parameter the image does not render and I just receive <vega.vegalite.VegaLite at 0xd793930>
I know in the documentation it states this could mean I need alt.renderers.enable('notebook')
, which I have already included.
Just curious if this is expected behavior or if I might be missing a step?
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (9 by maintainers)
Top GitHub Comments
I have just become that person! Apparently adding
alt.renderers.enable('mimetype')
to the notebook and then running papermill over it will make altair plots visible in the output notebook in Jupyter Lab.@dwanneruchi
Papermill works for me in Jupyterlab with the following setup:
Altair version: 3.0.1 Jupyterlab version: 1.0.0a3
AFAIK you must use the following command to get the pre-release of JL at the moment:
Then, as you may know, you have to set the cell’s metadata with a “parameters” tag, as follows:
Within a module (or using the CLI), call Papermill to execute the template notebook with the parameterization:
After that, the target notebook is created and the Altair charts are rendered as expected.
Al