简单直方图#

此示例展示了如何制作一个基本直方图,基于 vega-lite 文档 https://vega.github.io/vega-lite/examples/histogram.html

import altair as alt
from vega_datasets import data

source = data.movies.url

alt.Chart(source).mark_bar().encode(
    alt.X("IMDB_Rating:Q", bin=True),
    y='count()',
)
import altair as alt
from vega_datasets import data

source = data.movies.url

alt.Chart(source).mark_bar().encode(
    alt.X("IMDB_Rating:Q", bin=True),
    y='count()',
)
# No channel encoding options are specified in this chart
# so the code is the same as for the method-based syntax.