I tried to run the very nice tutorial, but see no output, using JupyterLab or notebook. Very puzzling, since the Chart.to_html method produces output that looks sensible.
The first time I run it, I get this warning:
/phys/users/tburnett/anaconda2/lib/python2.7/site-packages/altair/utils/core.py:110: FutureWarning: pandas.lib is deprecated and will be removed in a future version.
You can access infer_dtype as pandas.api.types.infer_dtype
typ = pd.lib.infer_dtype(data)
but I presume that it is irrelevant. But maybe using Python 2 is the problem?
Duplicate of: https://github.com/altair-viz/altair/issues/332
I guess multiple workarounds, either of which should work independently:
Also, should be useful looking the logic used to infer dtypes: https://github.com/altair-viz/altair/blob/master/altair/utils/core.py#L97
Thanks, that removes the warning, but your example,
from altair import datasets, Chart
cars = datasets.load_dataset('cars')
Chart(cars).mark_point().encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
color='Cylinders:Q' # Encode as quantitative (Q)
)
produces no output.
plt.plot(cars.Horsepower, cars.Miles_per_Gallon, 'o');
does.
I found the FAQ, and did an update with altair and vega, but I already have:
altair 1.2.0 py27_0 conda-forge
vega 0.4.4 py27_1 conda-forge
Can you open the Javascript console in your browser and let us know if it shows an error?
This is one of the issues we hope to fix in the future – currently Javascript errors don't show up in the jupyter notebook, which leads to a silent failure and makes debugging hard unless you know to look in the JS console.
This is all I see in the Chrome console: no additional output when running that example.
Upgraded: unknown to 0.25.2; Resetting DB.
[Deprecation] Resource requests whose URLs contain raw newline characters are deprecated, and may be blocked in M60, around August 2017. Please remove newlines from places like element attribute values in order to continue loading those resources. See https://www.chromestatus.com/features/5735596811091968 for more details.
default.js:652 Starting WebSocket: ws://localhost:8889/api/kernels/9ff8580f-5d5c-4709-85c7-70df692edb4c
No output in the Edge console either (Edge works fine otherwise).
The only thing I can think is that the jupyter extension may not be set up correctly. Can you run this in your terminal and then restart the notebook and try again?
jupyter nbextension install --sys-prefix --py vega
In the future, once we move to mimetype-based rendering, this extension will no longer be needed. But currently, it's how Jupyter knows to render Altair plots in the notebook.
Also, you're not using JupyterLab, are you? Currently Altair only works in the classic notebook. The next release will be compatible with JupyterLab as well.
Ah, sorry, Jake! I thought that I had checked that, my initial comment was in error. In fact, the plot representations were in the notebooks modified under JupyterLab, and suddenly the plots appeared when I opened the same notebook in Jupyter.
Trying too many new things at once (:-(. I want to switch to Jupyter, hope the next release is soon.
Thanks to you and other Udub people for this nice system. Don't know yet if I'll convert from my trusty matplotlib. It has the advantage of allowing me to move seamlessly from exploration to making pretty publication-quality plots. And it nicely supports multiple plots, and looks easier to make step histograms, the sort of plot I make most often.
Hi, my pd version '0.18.1', have tried specifying data type, still no plot / warning, have no clue at all. Any instructions? What does it mean to "Use Altair master"? Thanks.
Are you using JupyterLab or the classic notebook? The current release of Altair does not work in JupyterLab.
I'm using the classic one, not installed by pip though.
How did you install altair? Conda or pip or setup.py? Followup: if you didn't install via conda, did you follow the instructions and install the jupyter extension? Only conda does this automatically, and without the jupyter extension installed, plots won't show up.
Got it! The problem is I forgot to upgrade the notebook, thank you for your help and cheers on the excellent package.
Great!
I am using Jupyter Hub and do not have access to the global installation of jupyter. However, I was able to create an environment via conda and run Jake's suggestion jupyter nbextension install --sys-prefix --py vega. I then used a local version of jupyter_notebook_config.py in my ~/.jupyter/ directory where I used the config variable c.NotebookApp.extra_nbextensions_path = ['.conda/envs/name_of_my_env/share/jupyter/nbextensions/']
I'll eventually come up with a cleaner solution but maybe this will help someone else.
Most helpful comment
The only thing I can think is that the jupyter extension may not be set up correctly. Can you run this in your terminal and then restart the notebook and try again?
In the future, once we move to mimetype-based rendering, this extension will no longer be needed. But currently, it's how Jupyter knows to render Altair plots in the notebook.