【问题标题】:Python 3.6 - Altair Chart Prints Object, Not GraphPython 3.6 - Altair 图表打印对象,而不是图形
【发布时间】:2019-05-15 14:54:06
【问题描述】:

什么会导致图形对象不显示实际图形,而是显示图表?下面的可重现示例。

from pydataset import data
import altair

cars = data('cars')

cars

c = altair.Chart(cars).mark_line().encode(
    x='speed',
    y='dist'
)

输出

Chart({
  data:     speed  dist
  1       4     2
  2       4    10
  3       7     4
  4       7    22
  5       8    16
...
encoding: FacetedEncoding({
    x: X({
      shorthand: 'speed'
    }),
    y: Y({
      shorthand: 'dist'
    })
  }),
  mark: 'line'
})

预期的输出是一个图表,例如这里显示的https://altair-viz.github.io/user_guide/troubleshooting.html#display-troubleshooting

显然我已经阅读了故障排除,但我不清楚这个问题。他们谈论没有输出,但没有将对象作为输出。

编辑澄清:他们确实谈到了这一点,但特别是如果使用 Jupyter Notebook 和 IPython 被低估。我安装了 Jupyter,但没有使用。我已经安装了 IPython,但没有被低估。

【问题讨论】:

    标签: python graph data-visualization altair


    【解决方案1】:

    我安装了 Jupyter,但没有使用。

    如果您不使用 Jupyter 笔记本。 JupyterLab 或类似的笔记本环境,那么您将需要一些其他支持 Javascript 的前端来呈现图表。你可以在https://altair-viz.github.io/user_guide/display_frontends.html#display-general找到更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 1970-01-01
      • 1970-01-01
      • 2021-09-27
      相关资源
      最近更新 更多