
:orphan:
:html_theme.sidebar_secondary.remove:

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

.. _gallery_histogram_gradient_color:


Histogram with Gradient Color
-----------------------------
This example shows how to make a histogram with gradient color. 
The low-high IMDB rating is represented with the color scheme `pinkyellowgreen`.


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


    import altair as alt
    from altair.datasets import data

    source = data.movies.url

    alt.Chart(source).mark_bar().encode(
        alt.X("IMDB Rating:Q", 
            bin=alt.Bin(maxbins=20), 
            scale=alt.Scale(domain=[1, 10])
        ),
        alt.Y('count()'),
        alt.Color("IMDB Rating:Q", 
            bin=alt.Bin(maxbins=20), 
            scale=alt.Scale(scheme='pinkyellowgreen')
        )
    )

.. tab-set::

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

        .. code:: python


            import altair as alt
            from altair.datasets import data

            source = data.movies.url

            alt.Chart(source).mark_bar().encode(
                alt.X("IMDB Rating:Q").bin(maxbins=20).scale(domain=[1, 10]),
                alt.Y('count()'),
                alt.Color("IMDB Rating:Q").bin(maxbins=20).scale(scheme='pinkyellowgreen')
            )

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

        .. code:: python


            import altair as alt
            from altair.datasets import data

            source = data.movies.url

            alt.Chart(source).mark_bar().encode(
                alt.X("IMDB Rating:Q", 
                    bin=alt.Bin(maxbins=20), 
                    scale=alt.Scale(domain=[1, 10])
                ),
                alt.Y('count()'),
                alt.Color("IMDB Rating:Q", 
                    bin=alt.Bin(maxbins=20), 
                    scale=alt.Scale(scheme='pinkyellowgreen')
                )
            )