[英]Python Altair Vega chart not displaying
I have the following code snippet:我有以下代码片段:
import altair as alt
import pandas as pd
alt.renderers.enable('default')
data = pd.DataFrame({'a': list('CCCDDDEEE'),
'b': [2, 7, 4, 1, 2, 6, 8, 4, 7]})
chart = alt.Chart(data)
alt.Chart(data).mark_point().encode(
x='a',
y='b'
)
I have installed Altair and Vega and Notebook already:我已经安装了 Altair、Vega 和 Notebook:
Altair
version: 4.1.0 Altair
版本:4.1.0
Notebook
version: 6.4.0 Notebook
版本:6.4.0
Vega
version: 3.5.0 Vega
版本:3.5.0
Python
version: 3.7.8 Python
版本:3.7.8
http://localhost:8889/tree#notebooks
is open in a tab. http://localhost:8889/tree#notebooks
在选项卡中打开。
When I run my Python
program, nothing happens.当我运行
Python
程序时,什么也没有发生。
What am I missing?我错过了什么?
Try moving the enable line to just after importing altair, eg尝试在导入 altair 后将启用线移动到,例如
import altair as alt
alt.renderers.enable('default')
then restarting the kernel and re-running.然后重新启动内核并重新运行。 That seems to work for me.
这似乎对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.