我想使用 Python 2.7.12 和 Altair 1.2.0 可视化网页上的一些图表。
使用他们的例子很容易和直接:
from altair import *
from altair import Chart, load_dataset
# load built-in dataset as a pandas DataFrame
cars = load_dataset('cars')
chart = Chart(cars).mark_circle().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
)
chart.display()
这适用于 Jupyter Notebook。
更改chart.display()
为chart.server()
(如https://altair-viz.github.io/documentation/displaying.html#displaying-plots-via-a-local-http-server所述)应该足以使用 Python 的 HTTPServer 启动 Web 服务器。
它启动,但它提供的页面是空的。源在那里,但没有可视化。
知道为什么吗?