
:orphan:
:html_theme.sidebar_secondary.remove:

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

.. _gallery_beckers_barley_wrapped_facet:


Becker's Barley Wrapped Facet Plot
----------------------------------
The example demonstrates the faceted charts created by Richard Becker,
William Cleveland and others in the 1990s. Using the visualization technique
where each row is a different site (i.e. the chart is faceted by site),
they identified an anomaly in a widely used agriculatural dataset,
where the "Morris" site accidentally had the years 1931 and 1932 swapped.
They named this
`"The Morris Mistake." <http://ml.stat.purdue.edu/stat695t/writings/Trellis.User.pdf>`_.


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


    import altair as alt
    from altair.datasets import data

    source = data.barley.url

    alt.Chart(source).mark_point().encode(
        alt.X("median(yield):Q", scale=alt.Scale(zero=False)),
        y="variety:O",
        color="year:N",
        facet=alt.Facet("site:O", columns=2),
    ).properties(
        width=200,
        height=100,
    )


.. tab-set::

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

        .. code:: python


            import altair as alt
            from altair.datasets import data

            source = data.barley.url

            alt.Chart(source).mark_point().encode(
                alt.X("median(yield):Q").scale(zero=False),
                y="variety:O",
                color="year:N",
                facet=alt.Facet("site:O", columns=2),
            ).properties(
                width=200,
                height=100,
            )


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

        .. code:: python


            import altair as alt
            from altair.datasets import data

            source = data.barley.url

            alt.Chart(source).mark_point().encode(
                alt.X("median(yield):Q", scale=alt.Scale(zero=False)),
                y="variety:O",
                color="year:N",
                facet=alt.Facet("site:O", columns=2),
            ).properties(
                width=200,
                height=100,
            )
