
:orphan:
:html_theme.sidebar_secondary.remove:

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

.. _gallery_us_incomebrackets_by_state_facet:


US Income by State: Wrapped Facet
---------------------------------
This example shows how to create a map of income in the US by state,
faceted over income brackets 


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



    import altair as alt
    from altair.datasets import data

    states = alt.topo_feature(data.us_10m.url, 'states')
    source = data.income.url

    alt.Chart(source).mark_geoshape().encode(
        shape='geo:G',
        color='pct:Q',
        tooltip=['name:N', 'pct:Q'],
        facet=alt.Facet('group:N', columns=2),
    ).transform_lookup(
        lookup='id',
        from_=alt.LookupData(data=states, key='id'),
        as_='geo'
    ).properties(
        width=300,
        height=175,
    ).project(
        type='albersUsa'
    )# No channel encoding options are specified in this chart
    # so the code is the same as for the method-based syntax.


.. tab-set::

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

        .. code:: python



            import altair as alt
            from altair.datasets import data

            states = alt.topo_feature(data.us_10m.url, 'states')
            source = data.income.url

            alt.Chart(source).mark_geoshape().encode(
                shape='geo:G',
                color='pct:Q',
                tooltip=['name:N', 'pct:Q'],
                facet=alt.Facet('group:N', columns=2),
            ).transform_lookup(
                lookup='id',
                from_=alt.LookupData(data=states, key='id'),
                as_='geo'
            ).properties(
                width=300,
                height=175,
            ).project(
                type='albersUsa'
            )

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

        .. code:: python



            import altair as alt
            from altair.datasets import data

            states = alt.topo_feature(data.us_10m.url, 'states')
            source = data.income.url

            alt.Chart(source).mark_geoshape().encode(
                shape='geo:G',
                color='pct:Q',
                tooltip=['name:N', 'pct:Q'],
                facet=alt.Facet('group:N', columns=2),
            ).transform_lookup(
                lookup='id',
                from_=alt.LookupData(data=states, key='id'),
                as_='geo'
            ).properties(
                width=300,
                height=175,
            ).project(
                type='albersUsa'
            )# No channel encoding options are specified in this chart
            # so the code is the same as for the method-based syntax.
