
:orphan:
:html_theme.sidebar_secondary.remove:

.. This document is auto-generated by the altair-gallery extension. Do not modify directly.

.. _gallery_distributions_faceted_histogram:


Faceted Histogram
-----------------
This example shows how to make a basic faceted histogram,
with one histogram subplot for different subsets of the data.

Based off the vega-lite example:
https://vega.github.io/vega-lite/examples/trellis_bar_histogram.html


.. altair-plot::
    :remove-code:
    


    import altair as alt
    from altair.datasets import data

    source = data.cars()

    alt.Chart(source).mark_bar().encode(
        alt.X("Horsepower:Q", bin=True),
        y="count()",
        row="Origin",
    )


.. tab-set::

    .. tab-item:: Method syntax
        :sync: method

        .. code:: python


            import altair as alt
            from altair.datasets import data

            source = data.cars()

            alt.Chart(source).mark_bar().encode(
                alt.X("Horsepower:Q").bin(),
                y="count()",
                row="Origin",
            )


    .. tab-item:: Attribute syntax
        :sync: attribute

        .. code:: python


            import altair as alt
            from altair.datasets import data

            source = data.cars()

            alt.Chart(source).mark_bar().encode(
                alt.X("Horsepower:Q", bin=True),
                y="count()",
                row="Origin",
            )
